From: Hans-Werner Hilse <hwhilse@gmail.com>
To: User-mode-linux Devel <User-mode-linux-devel@lists.sourceforge.net>
Subject: Re: [uml-devel] [PATCH 2/3] um: Do not use stdin and stdout names for variables
Date: Thu, 11 Jun 2015 10:26:15 +0200 [thread overview]
Message-ID: <f8c70b0b8c5e2ceb7a65929ceb4d17a9@hilses.de> (raw)
In-Reply-To: <CAFLxGvyQuZ6aFZ3rVYT1v23nvVrTdx6vceKym1sHs3Brm_oc0A@mail.gmail.com>
Am 2015-06-11 10:09, schrieb Richard Weinberger:
> On Thu, Jun 11, 2015 at 9:54 AM, Hans-Werner Hilse <hwhilse@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
next prev parent reply other threads:[~2015-06-11 8:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <5578aa89.c7542b0a.5b46.ffffe036SMTPIN_ADDED_BROKEN@mx.google.com>
2015-06-10 21:37 ` [uml-devel] [PATCH 2/3] um: Do not use stdin and stdout names for variables Richard Weinberger
2015-06-11 6:35 ` Hans-Werner Hilse
2015-06-11 6:49 ` Richard Weinberger
2015-06-11 7:54 ` Hans-Werner Hilse
2015-06-11 8:09 ` Richard Weinberger
2015-06-11 8:26 ` Hans-Werner Hilse [this message]
2015-06-11 9:05 ` Richard Weinberger
2015-06-10 21:21 Hans-Werner Hilse
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f8c70b0b8c5e2ceb7a65929ceb4d17a9@hilses.de \
--to=hwhilse@gmail.com \
--cc=User-mode-linux-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox