Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

casts.h File Reference


Detailed Description

Functions for safer casting.

Author:
Christian Biere
Date:
2006

Go to the source code of this file.

Defines

#define UNSIGNED(value)   ((value) + ((guint64)0U))
 Implicit promotion to an unsigned integer.

Typedefs

typedef void(* func_ptr_t )(void)

Functions

G_GNUC_CONST WARN_UNUSED_RESULT
ALWAYS_INLINE gboolean * 
deconstify_gboolean (const gboolean *p)
 Cast a ``const gchar *'' to ``gchar *''.
G_GNUC_CONST WARN_UNUSED_RESULT
ALWAYS_INLINE gchar * 
deconstify_gchar (const gchar *p)
G_GNUC_CONST WARN_UNUSED_RESULT
ALWAYS_INLINE guint32 * 
deconstify_guint32 (const guint32 *p)
G_GNUC_CONST WARN_UNUSED_RESULT
ALWAYS_INLINE gpointer 
deconstify_gpointer (gconstpointer p)
G_GNUC_CONST WARN_UNUSED_RESULT
ALWAYS_INLINE gconstpointer 
cast_to_gconstpointer (gconstpointer p)
G_GNUC_CONST WARN_UNUSED_RESULT
ALWAYS_INLINE gpointer 
cast_to_gpointer (gpointer p)
G_GNUC_CONST WARN_UNUSED_RESULT
ALWAYS_INLINE gchar * 
cast_to_gchar_ptr (gpointer p)
G_GNUC_CONST WARN_UNUSED_RESULT
ALWAYS_INLINE guchar * 
cast_to_guchar_ptr (gpointer p)
G_GNUC_CONST WARN_UNUSED_RESULT
ALWAYS_INLINE gulong 
cast_ptr_to_uintptr (gpointer p)
 FIXME: Use uintptr_t if available.
G_GNUC_CONST WARN_UNUSED_RESULT
ALWAYS_INLINE gpointer 
cast_uintptr_to_ptr (gulong u)
 FIXME: Use uintptr_t if available.
G_GNUC_CONST WARN_UNUSED_RESULT
ALWAYS_INLINE gpointer 
cast_func_to_gpointer (func_ptr_t f)
G_GNUC_CONST WARN_UNUSED_RESULT
ALWAYS_INLINE func_ptr_t 
cast_gpointer_to_func (gconstpointer p)
size_t G_GNUC_CONST WARN_UNUSED_RESULT
ALWAYS_INLINE 
ptr_diff (gconstpointer a, gconstpointer b)
off_t G_GNUC_CONST WARN_UNUSED_RESULT
ALWAYS_INLINE 
filesize_to_off_t (filesize_t pos)
 Converts a filesize_t to off_t.


Define Documentation

#define UNSIGNED value   )     ((value) + ((guint64)0U))
 

Implicit promotion to an unsigned integer.

It allows to avoid comparision of signed values with unsigned values without resorting to harmful explicit casts.


Typedef Documentation

typedef void(* func_ptr_t)(void)
 


Function Documentation

G_GNUC_CONST WARN_UNUSED_RESULT ALWAYS_INLINE gpointer cast_func_to_gpointer func_ptr_t  f  )  [inline, static]
 

G_GNUC_CONST WARN_UNUSED_RESULT ALWAYS_INLINE func_ptr_t cast_gpointer_to_func gconstpointer  p  )  [inline, static]
 

G_GNUC_CONST WARN_UNUSED_RESULT ALWAYS_INLINE gulong cast_ptr_to_uintptr gpointer  p  )  [inline, static]
 

FIXME: Use uintptr_t if available.

G_GNUC_CONST WARN_UNUSED_RESULT ALWAYS_INLINE gchar* cast_to_gchar_ptr gpointer  p  )  [inline, static]
 

G_GNUC_CONST WARN_UNUSED_RESULT ALWAYS_INLINE gconstpointer cast_to_gconstpointer gconstpointer  p  )  [inline, static]
 

G_GNUC_CONST WARN_UNUSED_RESULT ALWAYS_INLINE gpointer cast_to_gpointer gpointer  p  )  [inline, static]
 

G_GNUC_CONST WARN_UNUSED_RESULT ALWAYS_INLINE guchar* cast_to_guchar_ptr gpointer  p  )  [inline, static]
 

G_GNUC_CONST WARN_UNUSED_RESULT ALWAYS_INLINE gpointer cast_uintptr_to_ptr gulong  u  )  [inline, static]
 

FIXME: Use uintptr_t if available.

G_GNUC_CONST WARN_UNUSED_RESULT ALWAYS_INLINE gboolean* deconstify_gboolean const gboolean *  p  )  [inline, static]
 

Cast a ``const gchar *'' to ``gchar *''.

This allows the compiler to print a diagnostic message if you accidently try to deconstify an incompatible type. A direct typecast would hide such a mistake.

G_GNUC_CONST WARN_UNUSED_RESULT ALWAYS_INLINE gchar* deconstify_gchar const gchar *  p  )  [inline, static]
 

G_GNUC_CONST WARN_UNUSED_RESULT ALWAYS_INLINE gpointer deconstify_gpointer gconstpointer  p  )  [inline, static]
 

G_GNUC_CONST WARN_UNUSED_RESULT ALWAYS_INLINE guint32* deconstify_guint32 const guint32 *  p  )  [inline, static]
 

off_t G_GNUC_CONST WARN_UNUSED_RESULT ALWAYS_INLINE filesize_to_off_t filesize_t  pos  )  [inline, static]
 

Converts a filesize_t to off_t.

Returns:
On failure (off_t) -1 is returned.

size_t G_GNUC_CONST WARN_UNUSED_RESULT ALWAYS_INLINE ptr_diff gconstpointer  a,
gconstpointer  b
[inline, static]
 


Generated on Sat Jun 30 17:53:25 2007 for gtk-gnutella by  doxygen 1.3.9.1