Discussion:
[Synce-devel] typedef void* HANDLE __attribute__((mode(SI)))
Pedro Alves
2006-10-18 16:44:21 UTC
Permalink
Hi all,

That warning about casting pointer to non pointer and vice-versa caused by:

/* A handle is usually a void*, but we must guarantee 32-bit! */
typedef uint32_t HANDLE;

... is annoying.

Would it be possible to change it to something like this?

#ifdef __GNUC__

typedef void* __attribute__((mode(SI))) HANDLE;
#else
typedef uint32_t HANDLE;
#endif

I don't have a 64-bit system to test this, but it should force HANDLE to 32 bits.

Cheers,
Pedro Alves
David Eriksson
2006-10-18 18:58:30 UTC
Permalink
Post by Pedro Alves
Hi all,
/* A handle is usually a void*, but we must guarantee 32-bit! */
typedef uint32_t HANDLE;
... is annoying.
Would it be possible to change it to something like this?
#ifdef __GNUC__
typedef void* HANDLE;
#else
typedef uint32_t HANDLE;
#endif
I don't have a 64-bit system to test this, but it should force HANDLE to 32 bits.
What does __attribute__((mode(SI))) mean?

\David
--
Pedro Alves
2006-10-18 23:37:00 UTC
Permalink
Post by David Eriksson
Post by Pedro Alves
Hi all,
/* A handle is usually a void*, but we must guarantee 32-bit! */
typedef uint32_t HANDLE;
... is annoying.
Would it be possible to change it to something like this?
#ifdef __GNUC__
typedef void* HANDLE;
#else
typedef uint32_t HANDLE;
#endif
I don't have a 64-bit system to test this, but it should force HANDLE to 32 bits.
What does __attribute__((mode(SI))) mean?
http://gcc.gnu.org/onlinedocs/gcc/Variable-Attributes.html

__attribute__ ((mode)) is documented here:
http://gcc.gnu.org/onlinedocs/gcc/Variable-Attributes.html

|mode (|mode|)|
This attribute specifies the data type for the declaration—whichever
type corresponds to the mode mode. This in effect lets you request
an integer or floating point type according to its width.

You may also specify a mode of `byte' or `__byte__' to indicate the
mode corresponding to a one-byte integer, `word' or `__word__' for
the mode of a one-word integer, and `pointer' or `__pointer__' for
the mode used to represent pointers.


About SI:
http://www.delorie.com/gnu/docs/gcc/gccint_53.html (SImode)

| SImode : |"Single Integer" mode represents a four-byte integer.

Cheers,
Pedro Alves

Loading...