summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2005-09-23 17:47:15 +0000
committerPaul Eggert <eggert@cs.ucla.edu>2005-09-23 17:47:15 +0000
commitef999bc74affb041cb6488413fca45f1be544128 (patch)
tree408ffb9e1f82b1d595086b0aa26cbdf2eb0082f2
parent6137da3427299f6dbcf0ae6e12335a3c87fc57e1 (diff)
downloadcoreutils-ef999bc74affb041cb6488413fca45f1be544128.tar.xz
(GL_CONCAT0, GL_CONCAT): Remove.
(verify): Don't use the __LINE__ trick, as it doesn't work in general. Instead, declare a function that returns a pointer to an array, and use verify_type__ to declare the size of the array. Problem and germ of a solution reported by Bruno Haible.
-rw-r--r--lib/verify.h28
1 files changed, 9 insertions, 19 deletions
diff --git a/lib/verify.h b/lib/verify.h
index c755762aa..828a42577 100644
--- a/lib/verify.h
+++ b/lib/verify.h
@@ -21,34 +21,24 @@
#ifndef VERIFY_H
# define VERIFY_H 1
-# define GL_CONCAT0(x, y) x##y
-# define GL_CONCAT(x, y) GL_CONCAT0 (x, y)
+/* Each of these macros 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. */
-/* A type that is valid if and only if R is nonzero.
- R should be an integer constant expression.
- verify_type__ and verify_error_if_negative_size__ are symbols that
- are private to this header file. */
+/* 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. */
# define verify_type__(R) \
struct { int verify_error_if_negative_size__ : (R) ? 1 : -1; }
-/* Verify requirement R at compile-time, as a declaration.
- R should be an integer constant expression.
- Unlike assert, there is no run-time overhead.
-
- The implementation uses __LINE__ to lessen the probability of
- generating a warning that verify_function_NNN is multiply declared.
- However, even if two declarations in different files have the same
- __LINE__, the multiple declarations are still valid C89 and C99
- code because they simply redeclare the same external function, so
- no conforming compiler will reject them outright. */
+/* Verify requirement R at compile-time, as a declaration. */
# define verify(R) \
- extern verify_type__ (R) GL_CONCAT (verify_function_, __LINE__) (void)
+ extern int (* verify_function__ (void)) [sizeof (verify_type__ (R))]
/* Verify requirement R at compile-time, as an expression.
- R should be an integer constant expression.
- Unlike assert, there is no run-time overhead.
This macro can be used in some contexts where verify cannot, and vice versa.
Return void. */