home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!taumet!steve
- From: steve@taumet.com (Steve Clamage)
- Subject: Re: assert
- Message-ID: <1992Dec21.163006.8068@taumet.com>
- Organization: TauMetric Corporation
- References: <HBF.92Dec19163113@gandalf.uio.no>
- Date: Mon, 21 Dec 1992 16:30:06 GMT
- Lines: 33
-
- hbf@gandalf.uio.no (Hallvard B Furuseth) writes:
-
- >assert is sometimes (ie sun or gcc) defined to call another macro (ie
- >__assert) which does most or all of the work. I expect it's a hack to
- >make sure the argument is stringified properly, or something like that.
- >Can somebody explain?
- >--
-
- It is probably invoking a function rather than another macro.
-
- "assert" has to print output on standard error, generally formatted
- in some nice way including the file and line number where the
- insertion failed as well as the failed assertion. The easiest way
- to do that is with fprintf().
-
- That in turn would mean that the assert header would have to include
- <stdio.h> to get the proper declarations, or duplicate the relevent
- declarations from <stdio.h>.
-
- The first alternative (#include <stdio.h>) is forbidden by the C
- Standard (standard headers may not #include other standard headers).
-
- The second is messy, and may cause interactions with user code.
- (It would impinge on your right to use identifiers from <stdio.h>
- when you don't include <stdio.h> in your code.)
-
- Probably the best solution is for the assert macro to call a function
- which is compiled separately and can therefore include whatever headers
- it needs. This function is often called something like __assert() or
- __gripe(), names which are reserved for the implementation.
- --
-
- Steve Clamage, TauMetric Corp, steve@taumet.com
-