From 220fdf4113f65771ab227646b2a0207c93a26148 Mon Sep 17 00:00:00 2001 From: James Laird Date: Wed, 19 Apr 2006 12:14:48 -0500 Subject: [svn-r12279] Purpose: Bug fix Description: When variables were declared in for loops C++ compiler on Cray X1 scoped them oddly, leading to compilation errors. Solution: Moved variable declarations out of for loops (where they probably shouldn't have been anyway) to the beginning of the function. Platforms tested: mir, Cray X1 (minor change) --- hl/c++/examples/ptExampleFL.cpp | 7 ++++--- hl/c++/examples/ptExampleVL.cpp | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/hl/c++/examples/ptExampleFL.cpp b/hl/c++/examples/ptExampleFL.cpp index ed754e9..4f9c167 100644 --- a/hl/c++/examples/ptExampleFL.cpp +++ b/hl/c++/examples/ptExampleFL.cpp @@ -28,13 +28,14 @@ int main(void) herr_t err; /* Return value from function calls */ hid_t fileID; /* HDF5 identifier for file */ hsize_t count; /* Number of records in table */ + int x; /* Temporary counter variable */ /* Buffers to hold data */ int readBuffer[5]; int writeBuffer[5]; /* Initialize buffers */ - for(int x=0; x<5; x++) + for(x=0; x<5; x++) { writeBuffer[x]=x; readBuffer[x] = -1; @@ -51,7 +52,7 @@ int main(void) fprintf(stderr, "Unable to create packet table."); /* Append five packets to the packet table, one at a time */ - for(int x=0; x<5; x++) + for(x=0; x<5; x++) { err = ptable.AppendPacket( &(writeBuffer[x]) ); if(err<0) @@ -69,7 +70,7 @@ int main(void) ptable.ResetIndex(); /* Iterate through packets, read each one back */ - for(int x=0; x<5; x++) + for(x=0; x<5; x++) { err = ptable.GetNextPacket( &(readBuffer[x]) ); if(err < 0) diff --git a/hl/c++/examples/ptExampleVL.cpp b/hl/c++/examples/ptExampleVL.cpp index 9c2b21f..1b41bfb 100644 --- a/hl/c++/examples/ptExampleVL.cpp +++ b/hl/c++/examples/ptExampleVL.cpp @@ -84,7 +84,7 @@ int main(void) ptable.ResetIndex(); /* Iterate through packets, read each one back */ - for(int x=0; x<5; x++) + for(x=0; x<5; x++) { err = ptable.GetNextPacket( &(readBuffer[x]) ); if(err < 0) -- cgit v0.12