Re: Caveat with lua_pushlightuserdata(L, (void *)&key)
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: Caveat with lua_pushlightuserdata(L, (void *)&key)
- From: Andreas Stenius <kaos@...>
- Date: 2006年6月26日 10:33:34 +0200
Julien Cugnière skrev:
Anyway, here is a simple way to ensure that your constants are unique
(assuming this legal C):
static const void* regkey1 = ®key1;
static const void* regkey2 = ®key2;
No, ®key1 is not a constant expression, although the result is constant.
I would use the __FILE__ and __LINE__ macros to get unique values,
unless space is an issue.
Something like:
#define STRINGIFY(a) #a
#define SAPPEND(s,i) s "" STRINGIFY(i)
#define UNIQUE_KEY SAPPEND(__FILE__, __FILE__)
static const char* unique_key = UNIQUE_KEY;
// just make sure not to have more than one key-macro per line
Regards,
Andreas