Date: Thu, 25 Mar 1999 14:22:06 +0100 From: Hans-Bernhard Broeker Message-Id: <199903251322.OAA16292@acp3bf.physik.rwth-aachen.de> To: djgpp AT delorie DOT com Subject: Re: Preprocessor hates sizeof Newsgroups: comp.os.msdos.djgpp Organization: RWTH Aachen, III. physikalisches Institut B X-Newsreader: TIN [version 1.2 PL2] Reply-To: djgpp AT delorie DOT com In article you wrote: > > >#if sizeof(long int)==sizeof(int) > I need something like that in a portable program to check if the structure > is not larger than a single allocation unit. The exact code is this: > #if (sizeof(Box) > BOXGRAIN) > #error Size of Box header cannot exceed size of grain. > #endif > Now I know that GCC does and will not support this, so how can I replace > it? Strictly spoken, you can't. Actually, you shouldn't even _want_ to do that. If your program really is meant to be 'portable', it shouldn't rely on anything as shaky as this. For a portable program, you'ld have to get rid of all fixed-size limits like that 'BOXGRAIN', above, e.g. by making a size-independant data structure by use of unions. Or you might isolate all such inescapable unportabilities in a small, separate portion of the source code, which will have to be ported from one architecture to the other, *manually*. -- Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de) Even if all the snow were burnt, ashes would remain.