Skip to content

Commit

Permalink
Corrected an issue encountered by the default compiler on ARM.
Browse files Browse the repository at this point in the history
  • Loading branch information
WardF committed Nov 7, 2017
1 parent 672c352 commit e7fee3e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion nc_test4/tst_converts.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,12 @@ main(int argc, char **argv)
unsigned char uchar_out[DIM1_LEN] = {0, 128, 255};
int format[MAX_NUM_FORMATS];
int num_formats;
int f = 0;

printf("\n*** Testing netcdf data conversion.\n");
determine_test_formats(&num_formats, format);

for (int f = 0; f < num_formats; f++)
for (f = 0; f < num_formats; f++)
{
printf("*** Testing conversion in netCDF %s files... ", format_name[f]);
create_file(format[f], uchar_out);
Expand Down

4 comments on commit e7fee3e

@edhartnett
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ARM compiler doesn't let you declare ints in the for loop?

Good to know since I do that everywhere.

@WardF
Copy link
Member Author

@WardF WardF commented on e7fee3e Nov 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be overcome with the appropriate flags, but by default it failed. We could add the flags to the configuration maybe, but for the time being this was a simple enough fix. Older versions of Visual Studio suffer from the same issue, actually, and I don't know what flags we'd need to set there, so this is probably better.

Error

/home/pi/Desktop/gitprojects/netcdf-c/nc_test4/tst_converts.c: In function ‘main’:
/home/pi/Desktop/gitprojects/netcdf-c/nc_test4/tst_converts.c:72:4: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
    for (int f = 0; f < num_formats; f++)
    ^
/home/pi/Desktop/gitprojects/netcdf-c/nc_test4/tst_converts.c:72:4: note: use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your code
nc_test4/CMakeFiles/nc_test4_tst_converts.dir/build.make:62: recipe for target 'nc_test4/CMakeFiles/nc_test4_tst_converts.dir/tst_converts.c.o' failed

@edhartnett
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, the PIO code as written depends on a lot of C99 features. In fact, I'm happy to say that if someone doesn't have C99, they should not use PIO.

I will put that into configure, and in doing non-PIO code I'll avoid C99. I'm pretty sure I can set some gcc flags for that so my Jenkins jobs will check this for me in the future...

@WardF
Copy link
Member Author

@WardF WardF commented on e7fee3e Nov 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good! As soon as the current test passes,

I'll get this group merged into master.

Please sign in to comment.