lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 02.12.11 14:31, Luiz Henrique de Figueiredo wrote:
'mykey' could be changed to a string it doesn't have to be an 'int'.

Note that I'm using the address of that int, not its value.
This address is guaranteed to be unique to the module.

For this reason, I think that

static char *mykey=MY_MODULE_NAME;

should be

static char mykey[]={MY_MODULE_NAME};

just in case the compiler removes duplicate copies of strings.

Using an array guarantees a unique address even if the string is used
elsewhere, even by a different module.

Why would changing to array notation change the mergability of these symbols? I have seen gcc guessing that a static array is constant (without the const declaration) so it can optimize more (which I guess also means removing duplicates).

Maybe volatile would help here?

--
regards,
Jakub Piotr Cłapa