Hi Joël, > Because recent gnulib has problems with read, write and close as > struct fields. I am still using: > > gnulib$ git log > commit 2d431ac35c4943a3655c07ba91870d2323321b43 (HEAD -> master, > origin/master, origin/HEAD) > > Here is my code: > > https://git.savannah.nongnu.org/cgit/gsequencer.git/tree/ags/object/ags_application_context.h#n112 > > Actually it fails here: > > https://git.savannah.nongnu.org/cgit/gsequencer.git/tree/ags/X/ags_xorg_application_context.c#n431 > > Here is a snipped of the terminal output: > > ags/X/ags_xorg_application_context.c:89: warning: "_GNU_SOURCE" redefined > 89 | #define _GNU_SOURCE > | > In file included from <command-line>: > ././ags/config.h:605: note: this is the location of the previous definition > 605 | # define _GNU_SOURCE 1 > | > In file included from ./ags/audio/midi/ags_midi_builder.h:29, > from ./ags/libags-audio.h:144, > from ./ags/X/ags_xorg_application_context.h:29, > from ags/X/ags_xorg_application_context.c:20: > ags/X/ags_xorg_application_context.c: In function > 'ags_xorg_application_context_class_init': > ags/X/ags_xorg_application_context.c:431:24: error: > 'AgsApplicationContextClass' {aka 'struct > _AgsApplicationContextClass'} has no member named '_write'; did you > mean 'write'? > 431 | application_context->write = ags_xorg_application_context_write; > | ^~~~~ > ags/X/ags_xorg_application_context.c:432:24: error: > 'AgsApplicationContextClass' {aka 'struct > _AgsApplicationContextClass'} has no member named '_read'; did you > mean 'read'? > 432 | application_context->read = ags_xorg_application_context_read; > |
Gnulib defines functions like 'read', 'write', 'close', etc. as C preprocessor macros, in order to avoid conflicts at the linker level. This is essential for the operation of Gnulib. So, 'write' may be defined to 'rpl_write' or to '_write', depending on the platform. (For some compilers, it would be possible to do this mapping at the C compiler level as opposed to the C preprocessor level. But this does not generalize to all compilers, therefore we are avoiding this approach.) Yes, unfortunately this can produce an error if you define a struct with a member 'write', then #include <unistd.h>, then use code that looks up the member 'write' - because at this point, 'write' expands to 'rpl_write' or '_write'. The workaround is simple: Make sure that you include the corresponding file - here <unistd.h> - before the struct definition. That is, in this case, at the beginning of ags/object/ags_application_context.h, add #include <unistd.h> Bruno