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 mailing list Tinycc-devel@nongnu.org http://lists.nongnu.org/mailman/listinfo/tinycc-devel