|
Yup, but one can do it inlined (sizeof(int)<sizeof(lua_Number)) ? "%0.f" : "%d" or (but requires some non-header change) const char* formatters[2] = { "%d", "%0.f" } formatters[ sizeof(int) < sizeof( lua_Number) ] Or this stupid trick, without requiring above: ("%d\0\0%0.f" + ((sizeof(int) < sizeof(lua_Number))<<2)) \0 is supposed to be 0 (I'm never sure how to encode this in "C") #define LUA_STRFORMAT_FLOATINGINT sizeof(int) < sizeof(lua_Number) #if LUA_STRFORMAT_FLOATINGINT #define LUA_STRFORMAT_INTEGER = "%.0f" #else #define LUA_STRFORMAT_INTEGER = "%d" On 7/28/2011 11:20 AM, Luiz Henrique de Figueiredo wrote:
I'd like to see this solved with defines in a config, with something like #define LUA_STRFORMAT_FLOATINGINT sizeof(int)< sizeof(lua_Number) #if LUA_STRFORMAT_FLOATINGINTThat cannot work because sizeof is not evaluated at preprocessing time.