From mboxrd@z Thu Jan 1 00:00:00 1970 To: 9fans@9fans.net Date: Thu, 10 Sep 2009 09:29:50 +0000 From: comeau@panix.com (Greg Comeau) Message-ID: References: <1d5d51400909090803n4c4d5b7ewba9dfe0573d02495@mail.gmail.com>, Subject: Re: [9fans] porting help please (gcc void pointer handling) Topicbox-Message-UUID: 6c19f66e-ead5-11e9-9d60-3106f5b1d025 In article , erik quanstrom wrote: >> gcc happily compiles a definition like >> #define CT_v249 ((void*)startLabel+464) >> > >no it doesn't. > >$ cat > x.c >char *startlab; >long long offset = (void*)startlab+464; >[...] >$ gcc -Wall x.c >x.c:2: error: initializer element is not constant That also has the issue of converting a void * to a long long, which may or may not work on the platform in question. Notwithstanding that, there's also the case where it may be say a non-static local which would be ok. Anyway, to the OP, eric's point is that the #define by itself may be fine, but *using it* as constant intializer is not, since the value of startLabel, if it's something like a char *, is not for use as a constant intiailizer (so adding 464 to it is not either). -- Greg Comeau / 4.3.10.1 with C++0xisms now in beta! Comeau C/C++ ONLINE ==> http://www.comeaucomputing.com/tryitout World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90. Comeau C/C++ with Dinkumware's Libraries... Have you tried it?