c++ - How to link an unreferenced variable in a separate cpp file in a static lib? -


here class definition below in "init.cpp":

//-------------------init.cpp----------------- // ... class cnetinit { public: cnetinit(){::wsastartup();} ~cnetinit() {...} };  static cnetinit s_initor; // ... //--------------------------------------------- 

i added cpp static library , , reference lib project, cnetinit's constructor can never executed because no there no reference cpp. how can make work without adding useless reference cpp importing unit?

comment: infact sample, code compiled in xcode , gcc, there standard or non-standard way(like compiler options) this?

you must compile file , link output other object files. way adding variable defined in application.


Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -