global const variable not getting assigned properly
Chad Scholes
cscholes@novell.com
Fri Dec 8 00:37:00 GMT 2006
I have the following global const defined at the top of a .cpp file:
const wchar_t * FILESPEC = L"filespec";
const unsigned int LEN_PATH = 5 + wcslen(FILESPEC) ;
Then in a class method I reference LEN_PATH:
printf("The length is %d\n", LEN_PATH);
LEN_PATH is 0 (zero). If I don't use the wide character version (change wchar_t to char and wcslen to strlen) then it works, I get LEN_PATH set to 13. Also, if I just assign LEN_PATH = 5 or LEN_PATH = 5 + 8, then it also works.
Any idea why it is 0 when using wcslen? And any idea why I'm not even getting an error to notify me of the problem?
Thanks!
More information about the Gcc-help
mailing list