One sad exception to this is MSVC, which is unlikely to ever get C99 support :c But luckily that isn't the compiler in use here
I'm in favor of -std=c99 /Tomas sön 2018-05-27 klockan 19:15 +0200 skrev Danilo Beuche: > Hi, > > instead of going back to the C syntax from the 1960's I would rather > suggest to adjust the build settings to use the C99 mode, as suggested > by the compiler error message. C99 is as the name suggests, from around > 1999, so all C compilers from within the last 10 years or so should have > no problem whatsoever with it. I haven't checked since which version C99 > is supported by gcc, but gcc 4.0 from 2007 does for sure. > > The command line option is -std=c99 > > Just my opinion. > > Regards, > Danilo > > > > On 27.05.2018 18:44, Matt Roberts wrote: > > When building the new codec2-0.8 library, I ran into a build error > > that I don't see in the 0.7 branch, even when the build environments > > are identical. > > > > A small 'diff' is below which will allow the library to build > > completely, along with a short explanation. > > > > ------------------------------ > > > > $ cmake -DCMAKE_BUILD_TYPE=Release ../codec2-0.8 > > > > -- The C compiler identification is GNU 4.8.4 > > -- Check for working C compiler: /usr/bin/cc > > -- Check for working C compiler: /usr/bin/cc -- works > > -- Detecting C compiler ABI info > > -- Detecting C compiler ABI info - done > > -- codec2 version: 0.8 > > -- Performing Test COMPILER_SUPPORTS_GNU11 > > -- Performing Test COMPILER_SUPPORTS_GNU11 - Success > > -- Build type is: Release > > -- Compiler Flags: -O2 -march=native -mtune=native -Wall -g -O3 > > -- Looking for include file stdlib.h > > -- Looking for include file stdlib.h - found > > -- Looking for include file string.h > > -- Looking for include file string.h - found > > -- Looking for floor > > -- Looking for floor - found > > -- Looking for ceil > > -- Looking for ceil - found > > -- Looking for pow > > -- Looking for pow - found > > -- Looking for sqrt > > -- Looking for sqrt - found > > -- Looking for sin > > -- Looking for sin - found > > -- Looking for cos > > -- Looking for cos - found > > -- Looking for atan2 > > -- Looking for atan2 - found > > -- Looking for log10 > > -- Looking for log10 - found > > -- Looking for round > > -- Looking for round - found > > -- Looking for getopt > > -- Looking for getopt - found > > -- Configuring done > > -- Generating done > > -- Build files have been written to: > > /home/mattro/Projects/freedv/build-codec2 > > > > $ make > > -- snip -- > > [ 35%] Building C object src/CMakeFiles/codec2.dir/freedv_api.c.o > > /home/mattro/Projects/freedv/codec2-0.8/src/freedv_api.c: In function > > ‘freedv_open_advanced’: > > /home/mattro/Projects/freedv/codec2-0.8/src/freedv_api.c:209:9: error: > > ‘for’ loop initial declarations are only allowed in C99 mode > > for (int i=0; i<f->interleave_frames*coded_syms_per_frame; i++) { > > ^ > > /home/mattro/Projects/freedv/codec2-0.8/src/freedv_api.c:209:9: note: > > use option -std=c99 or -std=gnu99 to compile your code > > /home/mattro/Projects/freedv/codec2-0.8/src/freedv_api.c:227:18: > > error: redefinition of ‘i’ > > for (int i=0; i<f->interleave_frames*f->n_nat_modem_samples; i++) { > > ^ > > /home/mattro/Projects/freedv/codec2-0.8/src/freedv_api.c:209:18: note: > > previous definition of ‘i’ was here > > for (int i=0; i<f->interleave_frames*coded_syms_per_frame; i++) { > > ^ > > /home/mattro/Projects/freedv/codec2-0.8/src/freedv_api.c:227:9: error: > > ‘for’ loop initial declarations are only allowed in C99 mode > > for (int i=0; i<f->interleave_frames*f->n_nat_modem_samples; i++) { > > ^ > > make[2]: *** [src/CMakeFiles/codec2.dir/freedv_api.c.o] Error 1 > > make[1]: *** [src/CMakeFiles/codec2.dir/all] Error 2 > > make: *** [all] Error 2 > > > > ------------------------------ > > > > The equivalent build steps for 0.7 work fine. Perhaps the "int i" > > could be moved out of the 'for' statement for maximum compiler > > compatibility? > > > > When I make that small change to lines 209 and 227, the 0.8 library > > builds fine. > > > > ------------------------------ > > > > diff -ur codec2-0.8/src/freedv_api.c codec2-0.8a/src/freedv_api.c > > --- codec2-0.8/src/freedv_api.c 2018-05-24 04:41:22.000000000 -0500 > > +++ codec2-0.8a/src/freedv_api.c 2018-05-27 11:38:20.986569633 -0500 > > @@ -206,7 +206,8 @@ > > if (f->codeword_symbols == NULL) {return NULL;} > > f->codeword_amps = > > (float*)malloc(sizeof(float)*f->interleave_frames*coded_syms_per_frame); > > if (f->codeword_amps == NULL) {return NULL;} > > - for (int i=0; i<f->interleave_frames*coded_syms_per_frame; > > i++) { > > + int i = 0; > > + for (i=0; i<f->interleave_frames*coded_syms_per_frame; i++) { > > f->codeword_symbols[i].real = 0.0; > > f->codeword_symbols[i].imag = 0.0; > > f->codeword_amps[i] = 0.0; > > @@ -224,7 +225,7 @@ > > > > f->mod_out = > > (COMP*)malloc(sizeof(COMP)*f->interleave_frames*f->n_nat_modem_samples); > > if (f->mod_out == NULL) { return NULL; } > > - for (int i=0; i<f->interleave_frames*f->n_nat_modem_samples; > > i++) { > > + for (i=0; i<f->interleave_frames*f->n_nat_modem_samples; i++) { > > f->mod_out[i].real = 0.0; > > f->mod_out[i].imag = 0.0; > > } > > > > ------------------------------ > > > > ------------------------------------------------------------------------------ > > > > Check out the vibrant tech community on one of the world's most > > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > > _______________________________________________ > > Freetel-codec2 mailing list > > Freetel-codec2@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/freetel-codec2 > > > ------------------------------------------------------------------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > _______________________________________________ > Freetel-codec2 mailing list > Freetel-codec2@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/freetel-codec2 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Freetel-codec2 mailing list Freetel-codec2@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/freetel-codec2