[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: proposal: stricter type-checking for macros
From: |
Paul Jarc |
Subject: |
Re: proposal: stricter type-checking for macros |
Date: |
Wed, 31 Mar 2004 18:08:22 -0500 |
User-agent: |
Gnus/5.110002 (No Gnus v0.2) Emacs/21.3 (gnu/linux) |
I wrote:
> #define TYPECHECK(x) (0? (void)(*(SCM*)0=(x)): (void)0)
BTW, does anyone know of a similar trick for arrays? I can do this:
#define ARRAYCHECK(type, arr) \
(0? (void)(*(type (**)[sizeof (arr)/sizeof (type)])0=&(arr)): (void)0)
But this requires the caller to know not just the element type of the
array, but also whether the array is const. (Pointer to array of
const T is not compatible with pointer to array of non-const T.) I'd
like to find a way to check that the expression is an array of const
or non-const T, giving a warning iff it is neither. (That way,
ARRAYCHECK(char, "foo") would work with or without -Wwrite-strings.)
paul