www.digitalmars.com         C & C++   DMDScript  

c++ - Preprocessor

reply Christof Meerwald <cmeerw web.de> writes:
#include <string.h>
#include <stdio.h>

#define STRINGIZE(a) DO_STRINGIZE(a)
#define

#define LONG_LONG long long

int main()
{
  const char *s = STRINGIZE(LONG_LONG);

  printf("%d\n", strlen(s));
  printf("\"%s\"\n", s);

  return 0;
}


The result is:

12
"long longýú"

Not exactly what I had expected, here is the string as it appears in the
object file (from obj2asm):

D0      db      06ch,06fh,06eh,067h,020h,06ch,06fh,06eh
        db      067h,0fdh,0fah,001h,000h


bye, Christof

-- 
http://cmeerw.org                                 JID: cmeerw jabber.at
mailto cmeerw at web.de

...and what have you contributed to the Net?
Dec 07 2002
parent Christof Meerwald <cmeerw web.de> writes:
This test-case is still a bit complex (and doesn't do anything useful):















#define COUNT_DOWN_C(D,N) 0
#define COUNT_DOWN_F(D,N) 0

enum { x = WHILE(COUNT_DOWN_C,COUNT_DOWN_F,0) };



This is what I get from DM (using -e -l):

enum { x =          WHILE_IIF_AB_HILE_CHECK_ù0()
(COUNT_DOWN_C,COUNT_DOWN_F,0) };


At least "WHILE_IIF_AB_HILE_CHECK_ù0" can't be correct.


BTW, this is what I get from gcc 3.0:

enum { x = WHILE_IIF_AB_WHILE_CHECK_0()(COUNT_DOWN_C,COUNT_DOWN_F,0) };


bye, Christof

-- 
http://cmeerw.org                                 JID: cmeerw jabber.at
mailto cmeerw at web.de

...and what have you contributed to the Net?
Dec 08 2002