assert or sqAssert? [was: Re: Source Forge Changes for 3.2.1]

John M McIntosh johnmci at smalltalkconsulting.com
Mon Dec 24 11:17:24 UTC 2001


>
>Not for the Linux version! *Where* happens this '#include <assert.h>'
>leading to this clash? There is no such include here.

Looking deeper into this it seems that assert.h is included by 
Apple's core foundation header. This header is gotten to by 
sqConfig.h which on the mac  under OS-X includes 
"/Developer/Headers/FlatCarbon/MacTypes.h" which

includes 
"/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/CarbonCore.h"
which includes
"/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h"

which at some point includes assert.h found at
"/usr/include/gcc/darwin/2.95.2/g++/../assert.h"


>
>I just wanted (I'm not really sure, see below) to have the most common
>ANSI-C assert. If your BSD assert (what means BSD here?) is such a thing,
>OK.



Below is the man page for the BSD (aka FreeBSD being the reference 
edition for OS-X) assert, but it seems the GNU assert is used here 
which overrides the platform definition for consistency according to 
notes on newsgroups from the 1990. The GNU assert.h is defined below 
(at least the interesting parts).

Thus either the assert used by LargeInteger.c uses the GNU assert, or 
platform assert, or it needs another name because it's not really 
assert.

GNU assert.h <partial>

extern void __eprintf () __attribute__ ((noreturn)); /* Defined in libgcc.a */

#define assert(expression)  \
   ((void) ((expression) ? 0 : __assert (expression, __FILE__, __LINE__)))

#define __assert(expression, file, lineno)  \
   (__eprintf ("%s:%u: failed assertion `%s'\n",         \
               file, lineno, "expression"), 0)

libgcc2.c has  <partial>

/* This is used by the `assert' macro.  */
extern void __eprintf (const char *, const char *, unsigned int, const char *)
   __attribute__ ((__noreturn__));

void
__eprintf (const char *string, const char *expression,
	   unsigned int line, const char *filename)
{
   fprintf (stderr, string, expression, line, filename);
   fflush (stderr);
   abort ();
}


BSD assert man page

ASSERT(3)                 System Programmer's Manual                 ASSERT(3)

NAME
      assert - expression verification macro

SYNOPSIS
      #include <assert.h>

      assert(expression)

DESCRIPTION
      The assert() macro tests the given expression and if it is false, the
      calling process is terminated.  A diagnostic message is written to stderr
      and the abort(3) function is called, effectively terminating the program.

      If expression is true, the assert() macro does nothing.

      The assert() macro may be removed at compile time with the cc(1) option
      -DNDEBUG.

DIAGNOSTICS
      The following diagnostic message is written to stderr if expression is
      false:

            "assertion \"%s\" failed: file \"%s\", line %d\n", \
                                "expression", __FILE__, __LINE__);

SEE ALSO
      cc(1),  abort(3)

STANDARDS
      The assert() macro conforms to ANSI C3.159-1989 (``ANSI C'').

HISTORY
      A assert macro appeared in Version 6 AT&T UNIX.

-- 
--
===========================================================================
John M. McIntosh <johnmci at smalltalkconsulting.com> 1-800-477-2659
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
===========================================================================




More information about the Squeak-dev mailing list