[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Tinycc-devel] More fun with comparison between pointer and integer.
From: |
Dave Dodge |
Subject: |
Re: [Tinycc-devel] More fun with comparison between pointer and integer... |
Date: |
Wed, 5 Sep 2007 18:32:06 -0400 |
User-agent: |
Mutt/1.5.13 (2006-08-11) |
On Wed, Sep 05, 2007 at 12:46:00PM -0500, Rob Landley wrote:
> On Wednesday 05 September 2007 3:25:59 am Dave Dodge wrote:
> > Pretty much the only way it seems to allow using a
> > pointer/address to an object _anywhere_ in a constant expression is in
> > sizeof context, or when the final expression is an address
>
> A constant string is an address once the (dynamic) linker's done with it.
Yes, but it's only guaranteed to be a constant expression by the
Standard if the final expression produces an address. Things like
this are well-defined and portable
static char * foo = "bar";
static char * foo = "bar" + 1;
but your case is not, because your final expression produces an
integer.
> The c89 standard didn't insist that char be 8 bytes, either.
ITYM 8 bits, and neither does the C99 Standard.
> Any platform on which it wasn't was too broken to worry about.
For Linux certainly. My understanding is that there are current
architectures in the embedded market that use a 32-bit char, though.
> (If you're curious what I'm doing, it's my toybox project, main.c,
> line 61.)
I see the problem. This adds more ugliness, but like most things you
can fix it with another layer of abstraction:
USE_ECHO(NEWTOY(echo, OPT_STR("+en"), TOYFLAG_BIN))
USE_TOYSH(NEWTOY(exit, OPT_NONE, TOYFLAG_NOFORK))
And then make the trivial definitions alongside NEWTOY and OLDTOY:
#define OPT_STR(x) x
#define OPT_NONE NULL
and
#define OPT_STR(x) 1
#define OPT_NONE 0
-Dave Dodge
- [Tinycc-devel] More fun with comparison between pointer and integer..., Rob Landley, 2007/09/05
- Re: [Tinycc-devel] More fun with comparison between pointer and integer..., Dave Dodge, 2007/09/05
- Re: [Tinycc-devel] More fun with comparison between pointer and integer..., Rob Landley, 2007/09/05
- Re: [Tinycc-devel] More fun with comparison between pointer and integer..., Dave Dodge, 2007/09/05
- Re: [Tinycc-devel] More fun with comparison between pointer and integer..., Rob Landley, 2007/09/05
- Re: [Tinycc-devel] More fun with comparison between pointer and integer...,
Dave Dodge <=
- Re: [Tinycc-devel] More fun with comparison between pointer and integer..., Rob Landley, 2007/09/05
- Re: [Tinycc-devel] More fun with comparison between pointer and integer..., Rob Landley, 2007/09/05
- Re: [Tinycc-devel] More fun with comparison between pointer and integer..., Simon 'corecode' Schubert, 2007/09/05
- Re: [Tinycc-devel] More fun with comparison between pointer and integer..., Rob Landley, 2007/09/06
- Re: [Tinycc-devel] More fun with comparison between pointer and integer..., Dave Dodge, 2007/09/05
- Re: [Tinycc-devel] More fun with comparison between pointer and integer..., Rob Landley, 2007/09/06
- Re: [Tinycc-devel] More fun with comparison between pointer and integer..., Dave Dodge, 2007/09/06
- Re: [Tinycc-devel] More fun with comparison between pointer and integer..., Gregg Reynolds, 2007/09/05
- Re: [Tinycc-devel] More fun with comparison between pointer and integer..., Rob Landley, 2007/09/05