Article View: comp.lang.c.moderated
Article #2492Re: Interesting compile-time assertion macro
From: Henning Makholm
Date: Thu, 04 Apr 1996 01:09
Date: Thu, 04 Apr 1996 01:09
24 lines
1251 bytes
1251 bytes
Mike Coffman <coffman@cat.com> writes:
>Mike Haertel wrote in comp.lang.c.moderated:
>> #define ASSERT_COMPILE_TIME(EXPR, KEY) \
>> struct ASSERT_COMPILE_TIME_##KEY { \
>> char ASSERT_COMPILE_TIME_##KEY[2*((EXPR) != 0) - 1]; \
>> }
>I usually use the sequence:
>
>#if test_condition
>#error error message
>#endif
>
>but, as you can see, this takes three lines to invoke to your one.
And, additionally, Mike H.'s macro accepts expressions involving
sizeof, which #if knows nothing about.
--
Henning Makholm - math and CS student - University of Copenhagen
makholm@diku.dk - http://www.diku.dk/students/makholm - fido 2:235/224.92
Technical Details
Message-ID:
<4jv7fu$d3m@solutions.solon.com>Path:
arc1-ca.pugleaf.net!solon.com!not-for-mailReferences:
<4jol55$1pi@solutions.solon.com> <4jq1lg$a67@solutions.solon.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail From: makholm@diku.dk (Henning Makholm) Newsgroups: comp.lang.c.moderated Subject: Re: Interesting compile-time assertion macro Date: 3 Apr 1996 19:09:18 -0600 Organization: Department of Computer Science, U of Copenhagen Sender: clc@solutions.solon.com Approved: clc@solutions.solon.com Message-ID: <4jv7fu$d3m@solutions.solon.com> References: <4jol55$1pi@solutions.solon.com> <4jq1lg$a67@solutions.solon.com> NNTP-Posting-Host: solutions.solon.com