NagiosEnterprises / ndoutils

NDOUtils - Database Output for Nagios Core
GNU General Public License v2.0
48 stars 21 forks source link

Implicit declaration of asprintf warnings still pop up #43

Closed orlitzky closed 6 years ago

orlitzky commented 7 years ago

There's a fix for this in include/nagios-4x/config.h:

/* stop gcc from bitching about implicit asprintf declarations */
#define _GNU_SOURCE 1

However I still see the following (among others):

make[2]: Entering directory '/home/mjo/src/ndoutils/src'
gcc -fPIC -fPIC -march=native -O2 -pipe -I/usr/include/mysql -I/usr/include/mysql/.. -DHAVE_CONFIG_H  -I ../include/nagios-4x  -D BUILD_NAGIOS_4X -o ndomod-4x.o ndomod.c  io.o utils.o -shared -Wl,-O1 -Wl,--as-needed  -lnsl 
ndomod.c: In function 'ndomod_write_to_sink':
ndomod.c:803:6: warning: implicit declaration of function 'asprintf' [-Wimplicit-function-declaration]
      asprintf(&temp_buffer,"ndomod: Successfully reconnected to data sink!  %lu
      ^
hedenface commented 7 years ago

I actually just fixed this in NRPE with a neat macro. I'll port it over on the next bugfix release.

Thanks!

hedenface commented 6 years ago

So, TIL that you can't just put a definition of _GNU_SOURCE in a header file and then include that header file elsewhere, according to the documentation (http://man7.org/linux/man-pages/man7/feature_test_macros.7.html).

To quote:

NOTE: In order to be effective, a feature test macro must be defined before including any header files. This can be done either in the compilation command (cc -DMACRO=value) or by defining the macro within the source code before including any headers.

hedenface commented 6 years ago

Should be fixed in maint as of: https://github.com/NagiosEnterprises/ndoutils/commit/eba5b7be13d994b46cc8251586f969eed5383ea8