On Fri, 25 Nov 2005 17:55:16 +0000 (UTC) "Henrik Grubbstr_m (Lysator) @ Pike (-) developers forum" 10353@lyskom.lysator.liu.se wrote:
I have a couple modules that are just plain CMODs, with no pike stub at all. Is there a way to put a couple of add_string_constant() calls into the PIKE_MODULE_INIT{} section that is generated from a CMOD? I tried just making an INIT{} section in the module outside of the classes, but that didn't work.
From a somewhat recent precompile.pike:
- AUTOMATIC ALLOCATION AND DEALLOCATION OF CONSTANT STRINGS
- You can use the syntax MK_STRING("my string") to refer to
- a struct pike_string with the content "my string", or the
- syntax MK_STRING_SVALUE("my string") for the same, but a
- full svalue. Note that this syntax can not be used in macros.
I'm not quite sure how this works. If I want to set the constant __version to be "1.1", how do I do that?
At the top-level? Something like the following might work:
PIKE_MODULE_INIT { INIT;
#ifdef EITHER add_constant(MK_STRING("__version"), MK_STRING_SVALUE("1.1"), 0); #else /* OR */ add_string_constant("__version", "1.1", 0); #endif }
Adam