This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: [PATCH] Add new cpp predef macro __SAFE_FILE__ to improve compile-time assertions.


On 24 April 2007 18:22, Richard Henderson wrote:

> On Sun, Apr 22, 2007 at 01:58:08PM +0100, Dave Korn wrote:
>>    A quick survey of the standard techniques for compile-time assertions[*]
>> reveals they all have to work around one underlying limitation of the
>> preprocessor: there's no way to automatically generate a (project-wide)
>> unique identifier using a preprocessor macro.
> 
> Why do you need one?
> 
> #define COMPILE_TIME_ASSERT(e) \
> 	extern int compile_time_assert[(e) ? 1 : -1]
> 
> External declarations can appear over and over again, provided
> that they are identical, and in this case the only time they
> aren't is when the assertion fails.
> 
> The unused external declaration merely gets discarded.

  Yes, you're correct (and only the second person to point this out), for some
reason (faulty memory?) I was expecting a common symbol to be emitted.

  Still, is there never another situation which might call for the ability to
generate a unique symbol using preprocessor macros?  Currently, it is
completely impossible.


    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]