From -452671240224906278 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 109fba,d7c5cd3d91064d70,start X-Google-Attributes: gid109fba,public X-Google-Thread: f78e5,bc2d9b2f726f122d X-Google-Attributes: gidf78e5,public X-Google-ArrivalTime: 1994-06-26 17:10:26 PST Newsgroups: comp.std.c++,comp.lang.c++ Path: bga.com!news.sprintlink.net!hookup!news.moneng.mei.com!howland.reston.ans.net!europa.eng.gtefsd.com!library.ucla.edu!csulb.edu!csus.edu!netcom.com!rfg From: rfg@netcom.com (Ronald F. Guilmette) Subject: Re: #if sizeof( int ) == 2 Message-ID: Followup-To: comp.lang.c++ Organization: Netcom Online Communications Services (408-241-9760 login: guest) References: Date: Sun, 26 Jun 1994 23:59:30 GMT Lines: 53 Xref: bga.com comp.std.c++:3025 comp.lang.c++:20111 In article bwh@kato.prl.ufl.edu (Brian Hook) writes: > >Borland C++ 3.1 compiles the following code 'correctly': > >#if sizeof( int ) == 2 >// assume 16-bit architecture >#endif > >Watcom C/C++ 10.0 does not, erroring on this. > >The ARM states (p. 377): > >"After any defined operators are evaluated, any remaining preprocessor >macros appearing in the constant expression will be prelaced as described >in $16.3. The resulting expression must be an integral constant expression >as defined in $5.19, EXCEPT THAT TYPES INT AND UNSIGNED INT ARE TREATED AS >LONG AND UNSIGNED LONG RESPECTIVELY, AND IT MAY NOT CONTAIN A CAST, A >SIZEOF OPERATOR, OR AN ENUMERATION CONSTANT." > >(Emphasis mine, obviously) > >Now, this seems fairly straightforward, which leads me to assume that >Borland's 3.1 compiler doesn't follow the ARM in this case. And have you got some hot news flashes for us on the Titanic perhaps? :-) But seriously folks, I have yet to find *any* C or C++ compiler that doesn't provide *some* non-standard extensions... usually by default. (Why do the vendors provide such things by default, rather than requiring a special option to enable them? It's a simple vendor-lock-in strategy. Everybody does it, and it's as old as the hills.) So caveat emptor.. and check your compiler manual. I have *also* yet to find *any* C or C++ compilers that fail to provide an option (or options) to DISABLE most/all of the non-standard vendor-specific extensions. Look for the option that mentions `ANSI'. If you care whether your code is portable or not, use it. Always. P.S. Least anyone be confused, it is my opinion that no one should fault Borland (or any other vendor for that matter) for providing a few non-standard extensions here and there. Remember that they also give you the ability to turn all of these things off, so what they've really given you is two... two... two compilers in one! (Likewise for all other compiler vendors.) Some people really like vendor A's extensions or vendor B's extensions, and they don't really care about portability. Those folks get to use the ``extended'' compiler, while others can still choose to use the ``standard'' compiler (via appropriate options). -- -- Ron Guilmette, Sunnyvale, CA ---------- RG Consulting ------------------- ---- domain addr: rfg@netcom.com ----------- Purveyors of Compiler Test ---- ---- uucp addr: ...!uunet!netcom!rfg ------- Suites and Bullet-Proof Shoes -