This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
void* vector
- From: "Alexey Smirnov" <alexey at gmail dot com>
- To: gcc at gcc dot gnu dot org
- Date: Sat, 9 Dec 2006 12:30:56 -0500
- Subject: void* vector
Hello,
I am trying to use vec.h to implement a vector of pointers:
typedef void* handle_t;
DEF_VEC_I(handle_t);
DEF_VEC_ALLOC_I(handle_t,heap);
extern VEC(handle_t,heap) *handles;
It does not compile:
In function 'VEC_handle_t_must_be_integral_type':
error: wrong type argument to bit-complement
The reason is the bit-complement test to decide if the supplied type
is integral or
not. It does not compile if void* is used:
(void)~(void*)0;
However, it is obviously possible to use void pointers along with
ints because they are equivalent on x86 as specified in i386.h:
#define Pmode (TARGET_64BIT ? DImode : SImode)
Therefore, we should use the mode of a constant of the type in
question to support void pointer vectors. That is, I would like to
use the following test:
__builtin_mode( (T) 0) == (TARGET_64BIT ? DImode : SImode)
Is a builtin like this available in GCC or not? Thanks,
Alexey