dpirch / libfvad

Voice activity detection (VAD) library, based on WebRTC's VAD engine
BSD 3-Clause "New" or "Revised" License
499 stars 176 forks source link

"-std=c11" is required #3

Closed twisteroidambassador closed 6 years ago

twisteroidambassador commented 6 years ago

While README.md states:

Recommended CFLAGS to turn on warnings: -std=c11 -Wall -Wextra -Wpedantic

It is actually required to use "-std=c11" for the compiled library to work, otherwise problems will arise either when compiling or importing. Maybe the flag should be added to the makefiles.

Tested with GCC 4.8.5: if no "-std" flags are specified, compilation fails with

fvad.c:75:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
     for (size_t i = 0; i < arraysize(valid_rates); i++) {
     ^
fvad.c:75:5: note: use option -std=c99 or -std=gnu99 to compile your code

and if "-std=c99" is specified, if the warnings are turned on, many warnings can be seen:

In file included from signal_processing/signal_processing_library.h:34:0,
                 from signal_processing/get_scaling_square.c:18:
signal_processing/spl_inl.h: In function ‘WebRtcSpl_CountLeadingZeros32’:
signal_processing/spl_inl.h:42:3: warning: implicit declaration of function ‘static_assert’ [-Wimplicit-function-declaration]
   RTC_COMPILE_ASSERT(sizeof(unsigned int) == sizeof(uint32_t));
   ^

using the compiled library will raise an error similar to "undefined symbol: static_assert".

dpirch commented 6 years ago

The "-std=gnu11" flag is now automatically added if necessary: ab268e50ca2dee08cd8cfb703edad3227f280d80

Newer versions of gcc and clang have c11 support enabled by default, but apparently gcc pre-5 uses "-std=gnu89" by default.