I\'m trying to initiate a static variable (inside a function) with malloc in C, but I\'m getting the \"initializer not constant error\". I know that I can\'t initiate a stat
C can't do that. C++ can with static constructors.
You could do the allocation first thing in main(), or in any other function that is called before your pointer is needed.
While nonportable, some executable formats such as the Classic Mac OS' Code Fragment Manager support initialization/termination entry points. The CFM initialization was used for C++ static construction. If the executable format on your platform supports an initialization entry point, you could use that.