Hi, I just checked what goes on in the codec2-dev/CMakelist.txt and I changed the (useless) GNU11/GNU99 "detection" to do something useful.
I tested this on Ubuntu 16.04 with 0.8. Index: CMakeLists.txt =================================================================== --- CMakeLists.txt (revision 3592) +++ CMakeLists.txt (working copy) @@ -55,9 +55,13 @@ # Set default C++ flags. include(CheckCCompilerFlag) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -g -O3") -CHECK_C_COMPILER_FLAG("-std=gnu11" COMPILER_SUPPORTS_GNU11) -if(CMAKE_C_STANDARD_COMPUTED_DEFAULT EQUAL "90") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99") + +if(COMPILER_SUPPORTS_GNU11) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11") +elseif(COMPILER_SUPPORTS_GNU99) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99") +else() + message( SEND_ERROR "Compiler doesm't seem to support at least gnu99, might cause problems" ) endif() # set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function") 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