diff options
author | Jim Meyering <jim@meyering.net> | 2005-06-30 16:39:41 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2005-06-30 16:39:41 +0000 |
commit | 5aa46e285c013f46867a2fa0ba98a4247cabf9e0 (patch) | |
tree | 781f2899f3176b7a04be8ecb522991e0256a1570 /lib/argmatch.h | |
parent | 4ff07ebe3c0ba36b97d6c2d50c524f2097cc3db7 (diff) | |
download | coreutils-5aa46e285c013f46867a2fa0ba98a4247cabf9e0.tar.xz |
[!VERIFY] (VERIFY): Define.
(ARGMATCH_VERIFY): Use it, so this macro may be used more than
once in any given scope.
Diffstat (limited to 'lib/argmatch.h')
-rw-r--r-- | lib/argmatch.h | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/argmatch.h b/lib/argmatch.h index ea0f46800..45bfa03a7 100644 --- a/lib/argmatch.h +++ b/lib/argmatch.h @@ -1,6 +1,6 @@ /* argmatch.h -- definitions and prototypes for argmatch.c - Copyright (C) 1990, 1998, 1999, 2001, 2002, 2004 Free Software + Copyright (C) 1990, 1998, 1999, 2001, 2002, 2004, 2005 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify @@ -25,6 +25,15 @@ # include <stddef.h> +# ifndef VERIFY +# define GL_CONCAT0(x, y) x##y +# define GL_CONCAT(x, y) GL_CONCAT0 (x, y) +/* Verify a requirement at compile-time (unlike assert, which is runtime). */ +# define VERIFY(assertion) \ + struct GL_CONCAT (compile_time_assert_, __LINE__) \ + { char a[(assertion) ? 1 : -1]; } +# endif + # define ARRAY_CARDINALITY(Array) (sizeof (Array) / sizeof *(Array)) # define ARGMATCH_CONSTRAINT(Arglist, Vallist) \ @@ -35,11 +44,8 @@ preferred, since it is guaranteed to be checked at compile-time. ARGMATCH_ASSERT is for backward compatibility only. */ -# define ARGMATCH_VERIFY(Arglist, Vallist) \ - struct argmatch_verify \ - { \ - char argmatch_verify[ARGMATCH_CONSTRAINT(Arglist, Vallist) ? 1 : -1]; \ - } +# define ARGMATCH_VERIFY(Arglist, Vallist) \ + VERIFY (ARGMATCH_CONSTRAINT (Arglist, Vallist)) # define ARGMATCH_ASSERT(Arglist, Vallist) \ assert (ARGMATCH_CONSTRAINT (Arglist, Vallist)) |