Date: Thu, 25 Mar 1999 10:45:45 -0500 Message-Id: <199903251545.KAA23500@envy.delorie.com> From: DJ Delorie To: djgpp AT delorie DOT com In-reply-to: (message from Wojciech Piechowski on Thu, 25 Mar 1999 10:02:05 +0100 (MET)) Subject: Re: Preprocessor hates sizeof References: Reply-To: djgpp AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk > #if (sizeof(Box) > BOXGRAIN) The problem is that the #if lines are handled by the preprocessor, but the sizeof() functions are handled by the compiler. The preprocessor doesn't have enough information to figure out what sizeof() is. So, the only option (and the most portable one) is to do these checks while the program is running, like this: main() { assert(sizeof(Box) <= BOXGRAIN); Then, you can turn on/off the assertion checks via -DNDEBUG (defining it disables all assertions for speed).