From e1d072571ec6f9d830e575a2ecdc95fd43428e53 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 31 Aug 2001 16:46:07 -0300 Subject: better syntax for type casts --- lobject.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'lobject.h') diff --git a/lobject.h b/lobject.h index 9170d81b..415f8080 100644 --- a/lobject.h +++ b/lobject.h @@ -1,5 +1,5 @@ /* -** $Id: lobject.h,v 1.109 2001/06/28 14:56:25 roberto Exp roberto $ +** $Id: lobject.h,v 1.110 2001/08/27 15:16:28 roberto Exp $ ** Type definitions for Lua objects ** See Copyright Notice in lua.h */ @@ -22,6 +22,10 @@ #endif +#ifndef cast +#define cast(t, exp) ((t)(exp)) +#endif + /* tags for values visible from Lua == first user-created tag */ #define NUM_TAGS 6 @@ -96,7 +100,7 @@ typedef union TString { } TString; -#define getstr(ts) ((l_char *)((ts) + 1)) +#define getstr(ts) cast(l_char *, (ts) + 1) #define svalue(o) getstr(tsvalue(o)) @@ -196,7 +200,7 @@ typedef struct Hash { /* ** `module' operation for hashing (size is always a power of 2) */ -#define lmod(s,size) ((int)((s) & ((size)-1))) +#define lmod(s,size) (cast(int, (s) & ((size)-1))) /* @@ -217,7 +221,7 @@ typedef struct CallInfo { extern const TObject luaO_nilobject; -#define luaO_openspace(L,n,t) ((t *)luaO_openspaceaux(L,(n)*sizeof(t))) +#define luaO_openspace(L,n,t) cast(t *, luaO_openspaceaux(L,(n)*sizeof(t))) void *luaO_openspaceaux (lua_State *L, size_t n); int luaO_equalObj (const TObject *t1, const TObject *t2); -- cgit v1.2.3-55-g6feb