delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1997/07/09/17:54:39

Message-Id: <199707092153.RAA04584@delorie.com>
From: Oberhumer Markus <k3040e4 AT c210 DOT edvz DOT uni-linz DOT ac DOT at>
Subject: <assert.h> patch
To: djgpp-workers AT delorie DOT com (djgpp-workers), dj AT delorie DOT com (DJ Delorie)
Date: Wed, 9 Jul 1997 23:48:23 +0200 (METDST)
Return-Read-To: markus DOT oberhumer AT jk DOT uni-linz DOT ac DOT at
Mime-Version: 1.0

The current implementation of <assert.h> causes warnings when
using compile-time expressions that evaluate to true (like `assert(1);')
in combination with the gcc flags `-Wall -pedantic'.

Below is my new version of assert.h - it has been closely modelled
after the one found in the Linux libc.

There still exist problems with `-traditional' because of stringizing
issues, but we probably don't want to work around this.

Markus


/* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */
#ifndef __dj_ENFORCE_ANSI_FREESTANDING

#undef assert

#if defined(NDEBUG)
#define assert(expr) ((void)0)
#else
#define assert(expr) ((void)((expr)||(__dj_assert(#expr,__FILE__,__LINE__),0)))
#endif

#ifndef __dj_include_assert_h_
#define __dj_include_assert_h_

#ifdef __cplusplus
extern "C" {
#endif

void __dj_assert(const char *,const char *,int) __attribute__((__noreturn__));

#ifdef __cplusplus
}
#endif

#endif /* !__dj_include_assert_h_ */

#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019