Am 2015-06-11 10:09, schrieb Richard Weinberger: > On Thu, Jun 11, 2015 at 9:54 AM, Hans-Werner Hilse <hwhi...@gmail.com> > wrote: >> About forbidden use of names/identifiers from the stdlib, the C >> standard >> is a bit hard for me to grasp fully. However, I think C99 7.1.3 >> paragraph 1, 3rd point is relevant here: "Each macro name in any of >> the >> following subclauses (including the future library directions) is >> reserved for use as specified if any of its associated headers is >> included; unless explicitly stated otherwise (see 7.1.4)." > > Yeah, but we're talking about structure members.
Indeed, and I can't find more detail about the "reserved for use as specified" part. I think it is saying, though, that those identifiers are macros (and as such will get expanded). The preprocessor will not care if that's in a struct member name. >> So aside from renaming struct members, another option would be to lift >> the macro definition by an "#undef" in relevant places. I have a >> feeling, though, that this faces new problems with the C99 standard, >> 7.1.3 paragraph 3, which says that "If the program removes (with >> #undef) >> any macro definition of an identifier in the first group listed above, >> the behavior is undefined." > > So, what exactly is the build error you're facing and how can I > reproduce? Of course I should have told you in the first place: [hw@hilses linux-uml]$ make ARCH=um CC="musl-gcc" ... CC arch/um/drivers/slip_user.o In file included from arch/um/drivers/slip_user.c:12:0: /usr/lib/musl/include/sys/termios.h:1:2: warning: #warning redirecting incorrect #include <sys/termios.h> to <termios.h> [-Wcpp] #warning redirecting incorrect #include <sys/termios.h> to <termios.h> ^ In file included from arch/um/drivers/slip_user.c:6:0: arch/um/drivers/slip_user.c: In function ‘slip_pre_exec’: arch/um/drivers/slip_user.c:67:12: error: expected identifier before ‘(’ token if (data->stdin >= 0) ^ arch/um/drivers/slip_user.c:68:14: error: expected identifier before ‘(’ token dup2(data->stdin, 0); ^ arch/um/drivers/slip_user.c:68:3: error: too few arguments to function ‘dup2’ dup2(data->stdin, 0); ^ (We can ignore the warning for now/this discussion, I think.) You can reproduce without actually installing a musl toolchain when changing glibc's macro definition to musl's: make ARCH=um CFLAGS="-Dstdout=\\(stdout\\)" Will trigger the same error in the same place. Of course, this is artificially producing it. Using musl, however, leads to the same behaviour. I used the defconfig, that's why it triggers in slip_user.c first - other places do use stdin/stdout as struct member name, too. -hwh ------------------------------------------------------------------------------ _______________________________________________ User-mode-linux-devel mailing list User-mode-linux-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel