comp.lang.ada
 help / color / mirror / Atom feed
From: "Jean-Pierre Rosen" <rosen@adalog.fr>
Subject: Re: Static assertions
Date: Mon, 21 May 2001 09:50:50 +0200
Date: 2001-05-21T09:50:50+02:00	[thread overview]
Message-ID: <9eahad$6ks$1@s1.read.news.oleane.net> (raw)
In-Reply-To: pdx7kzd3fdb.fsf@sirppi.helsinki.fi

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1061 bytes --]


"Aaro Koskinen" <aaro@iki.fi> a �crit dans le message news:
pdx7kzd3fdb.fsf@sirppi.helsinki.fi...
> "Jean-Pierre Rosen" <rosen@adalog.fr> writes:
> > Still discovering how powerful Ada is...
> >
> > Imagine your program relies on Integer having a certain size, or being
sure
> > that the size of Integer is four times the size of character, or things
like
> > that, and you want to make sure that the program does not even compile
if
> > the assertions do not hold (because you hate fighting with a debugger).
This
> > is possible, since a static expression that raises constraint_error will
not
> > compile.
>
> I have been using a similar method in C. I have an assert macro, which
> declares a const int with the value "1 / <static boolean expression>".
> If the assertion does not hold, it evaluates to 0, and the code will
> not compile.
>
Out of curiosity... Is this *required* by the C standard ?

--
---------------------------------------------------------
           J-P. Rosen (rosen@adalog.fr)
Visit Adalog's web site at http://www.adalog.fr





  reply	other threads:[~2001-05-21  7:50 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-05-17 15:07 Static assertions Jean-Pierre Rosen
2001-05-17 17:44 ` Jeffrey Carter
2001-05-17 19:09   ` Marin David Condic
2001-05-17 22:34     ` Jeffrey Carter
2001-05-18 13:39       ` Marin David Condic
2001-05-18  1:23 ` Robert A Duff
2001-05-19  7:40 ` David Kristola
2001-05-19 22:56   ` Robert A Duff
2001-05-19  8:36 ` Aaro Koskinen
2001-05-21  7:50   ` Jean-Pierre Rosen [this message]
2001-06-12  3:59     ` David Thompson
  -- strict thread matches above, loose matches on Subject: below --
2001-05-18  5:34 Christoph Grein
2001-05-18 13:38 ` Robert A Duff
2001-05-18 16:15   ` Jeffrey Carter
2001-05-18 17:25     ` Ted Dennison
2001-05-18 21:27     ` Robert A Duff
2001-05-18 22:46       ` Jeffrey Carter
2001-05-19 22:53         ` Robert A Duff
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox