2005-07-04 16:05:41 +00:00
|
|
|
/* Compile-time assert-like macros.
|
|
|
|
|
|
|
|
|
|
Copyright (C) 2005 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
|
any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software Foundation,
|
|
|
|
|
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
|
|
|
|
|
2005-07-05 05:16:08 +00:00
|
|
|
/* Written by Paul Eggert and Jim Meyering. */
|
|
|
|
|
|
2005-07-04 16:05:41 +00:00
|
|
|
#ifndef VERIFY_H
|
|
|
|
|
# define VERIFY_H 1
|
|
|
|
|
|
2005-09-23 17:52:22 +00:00
|
|
|
/* Each of these macros verifies that its argument R is a nonzero
|
|
|
|
|
constant expression. To be portable, R's type must be integer (or
|
|
|
|
|
boolean). Unlike assert, there is no run-time overhead. */
|
2005-07-05 05:16:08 +00:00
|
|
|
|
2005-09-23 17:47:15 +00:00
|
|
|
/* A type that is valid if and only if R is a nonzero constant expression.
|
|
|
|
|
The symbols verify_type__ and verify_error_if_negative_size__ are
|
|
|
|
|
private to this header file. */
|
2005-07-05 05:16:08 +00:00
|
|
|
|
|
|
|
|
# define verify_type__(R) \
|
2005-09-23 23:05:39 +00:00
|
|
|
struct { unsigned int verify_error_if_negative_size__ : (R) ? 1 : -1; }
|
2005-07-05 05:16:08 +00:00
|
|
|
|
2005-09-23 17:47:15 +00:00
|
|
|
/* Verify requirement R at compile-time, as a declaration. */
|
2005-07-05 05:16:08 +00:00
|
|
|
|
|
|
|
|
# define verify(R) \
|
2005-09-23 17:47:15 +00:00
|
|
|
extern int (* verify_function__ (void)) [sizeof (verify_type__ (R))]
|
2005-07-05 05:16:08 +00:00
|
|
|
|
|
|
|
|
/* Verify requirement R at compile-time, as an expression.
|
|
|
|
|
This macro can be used in some contexts where verify cannot, and vice versa.
|
|
|
|
|
Return void. */
|
|
|
|
|
|
2005-07-11 23:28:09 +00:00
|
|
|
# define verify_expr(R) ((void) ((verify_type__ (R) *) 0))
|
2005-07-04 16:05:41 +00:00
|
|
|
|
|
|
|
|
#endif
|