Hi Folks!
In a C wrapper file, I have the declaration
/* xmlc.c */ const char* _c_CXML_DEFAULT_VERSION = XML_DEFAULT_VERSION;
Now, I would like to use it in pascal.
{ xml.pas, Unit } unit XML;
interface
var C_HELPER_XML_DEFAULT_VERSION: CString; external name '_c_CXML_DEFAULT_VERSION'; attribute (const);
XML_DEFAULT_VERSION: TString = CString2String (C_HELPER_XML_DEFAULT_VERSION);
implementation {$L xmlc.c} end.
Using this unit results in an error: "cannot evaluate this expression from a global declaration" "Error initial value is of wrong type".
How can I use my string constant in GPC?
Eike
Eike Lange wrote:
In a C wrapper file, I have the declaration
/* xmlc.c */ const char* _c_CXML_DEFAULT_VERSION = XML_DEFAULT_VERSION;
Now, I would like to use it in pascal.
{ xml.pas, Unit } unit XML;
interface
var C_HELPER_XML_DEFAULT_VERSION: CString; external name '_c_CXML_DEFAULT_VERSION'; attribute (const);
XML_DEFAULT_VERSION: TString = CString2String (C_HELPER_XML_DEFAULT_VERSION);
implementation {$L xmlc.c} end.
Using this unit results in an error: "cannot evaluate this expression from a global declaration" "Error initial value is of wrong type".
How can I use my string constant in GPC?
Which GPC version? I think most recent ones should be able to do this. (But if it works after an upgrade, please test it well as it's rather new code.)
If it doesn't work, or if you want to support older GPC versions, you can use an assignment in a module initializer (`to begin do').
Frank