CompuServe Thread

Size_t existence

4 messages in this thread
#7434From: Phil ShapiroJul 23, 1993 7:42 AM
"Is there some way I can portably check if size_t is around, short of re-editing your standard #include files to act like the other compilers?" By definition, there no "portable" way to check if size_t has been defined. Instead, you should just #include the header file that defines size_t, which is <stddef.h>. The ANSI (er, ISO) C standard makes no claims about checking to see if a name is defined. -phil
#7466From: SyndesisJul 23, 1993 12:24 PM
I understand there's no "portable", standardized way to do this. It just "happens" that Microsoft, Borland, Manx, several Unix compilers, the Metaware compiler, etc. "happened" to use this #define method. Why does Think C use this custom pragma to do the job, when a more useful alternative exists?
#7553From: Robert S. Mah[OSB]Jul 25, 1993 11:30 AM
I agree with John. The #pragma once directive always struck me as superfluous. The #ifndef/#define/#endif trio _is_ a de-facto standard among most C programmers. BTW, I have also been hit by the size_t problem and just added the trio myself, but having it included would have been nice. Cheers, Rob
#7580From: Joe SewellJul 25, 1993 10:19 PM
–> Why does Think C use this custom pragma to do the job, when a more useful alternative exists? <– I disagree that the THINK C #pragma once (I presume that's what you mean) is less useful. Indeed, it helps ensure that you don't accidentally include a file more than once, thereby redefining stuff all over creation. It's automatic, too, unlike the more manual methods. FWIW, #pragma once is the same as #define _H_includefile, which is the same as the old #ifndef _H_includefile/#define _H_includefile/etc/#endif. You can even check for the existence of the preprocessor symbol _H_includefile. FWIW #2, Microsoft C (nit-pick: the product name isn't "Microsoft," even though I'm sure those arrogant b**t**ds enjoy having their name used as "the standard") does several things in a non-standard way, including merging the preprocessor symbol table with the compiler symbol table. This means you can #ifdef on a typedef name, for example. It's not necessarily AGAINST the standard, I suppose, but it's NOT something that's safe to depend upon. Joe