79653550

Date: 2025-06-04 21:59:13
Score: 0.5
Natty:
Report link

You're running into this because szCopyright, while declared const, isn't a constant expression from the compiler's point of view during the compilation of other modules. In C, only literal constants can be used to initialize variables with static storage duration, like your myReference. The workaround is to take the address of szCopyright instead, which is a constant expression, like this: static const void *myReference = &szCopyright;. This ensures the symbol gets pulled into the final link without violating compiler rules. Just make sure szCopyright is defined in only one .c file and declared extern in the header.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Single line (0.5):
  • Low reputation (1):
Posted by: Karen Brewer