#undef, #define
From: Christopher Benson-Manica (ataru_at_nospam.cyberspace.org)
Date: 03/30/04
- Next message: Default User: "Re: Hey, im a noob at C, PLEASE READ"
- Previous message: Sworn Democrats will vote for Detestable Bush: "$$ WHY DEMOCRATS WILL VOTE FOR BUSH $$"
- Next in thread: Alex Monjushko: "Re: #undef, #define"
- Reply: Alex Monjushko: "Re: #undef, #define"
- Reply: Bertrand Mollinier Toublet: "Re: #undef, #define"
- Reply: Mac: "Re: #undef, #define"
- Reply: Dan Pop: "Re: #undef, #define"
- Reply: Old Wolf: "Re: #undef, #define"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 29 Mar 2004 22:58:32 +0000 (UTC)
(assume for the purposes of this question that the implementation is
C89-compliant)
Let us say that the following lines exist in a certain header file:
#if !defined(BOOLEAN_T)
#define BOOLEAN_T
typedef unsigned short boolean;
#endif
And let us further say that the following line is found in another
header:
typedef unsigned char boolean;
Finally, suppose that the first header has already been preprocessed
by the time the line in the second header is reached. How does one
ensure that boolean is only defined once? I've tried
#undef boolean
#ifndef boolean
#ifndef BOOLEAN_T
and none of them seem to prevent boolean from being redefined by the
second header file and leading to fatal compile-time errors. Any
suggestions, besides cursing the name of he who wrote the first header
file?
(The players in this little drama are def.h, the company standard
header file, yuk yuk, and a standard header file for an updated
version of my implementation.)
-- Christopher Benson-Manica | I *should* know what I'm talking about - if I ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
- Next message: Default User: "Re: Hey, im a noob at C, PLEASE READ"
- Previous message: Sworn Democrats will vote for Detestable Bush: "$$ WHY DEMOCRATS WILL VOTE FOR BUSH $$"
- Next in thread: Alex Monjushko: "Re: #undef, #define"
- Reply: Alex Monjushko: "Re: #undef, #define"
- Reply: Bertrand Mollinier Toublet: "Re: #undef, #define"
- Reply: Mac: "Re: #undef, #define"
- Reply: Dan Pop: "Re: #undef, #define"
- Reply: Old Wolf: "Re: #undef, #define"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|