in c++, i use template class AutoRegisterTemplate to do some automatic registration in…
Jump to turn (7)
- 1in c++, i use template class AutoRegisterTemplate to do some automatic registrat
- 2i got redefinition error after writing extern AutoRegisterTemplate filelocalvar;
- 3i already tried this // mymodulea.h #pragma once #include “AutoRegisterTemplate.
- 4give me example of /include: linker flag that inlude multiple files
- 5aside from /INCLUDE , is there other way to tell compiler to link certain source
- 6are there ways to do this, inside c++ code, not set linker flags
- 7aside from /INCLUDE , are there ways to tell compiler to link certain source fil
- User
in c++, i use template class AutoRegisterTemplate to do some automatic registration in class constructor. Suppose ModuleClass is the template parameter, for different ModuleClass , the constructor extract their
ModuleClass::Registerfunction pointer in a static std::map variable all_register_funcs. Now i have this problem, I writestatic AutoRegisterTemplate<ModuleClassA> file_local_varin a .cpp file my_module_a.cpp, hoping ModuleClassA will trigger it's constructor and inturn put ModuleClassA::Register pointer into theall_register_funcs. However, when I run the program, the .cpp file my_module_a.cpp was never linked, it seems that this cpp file was optimized away by linker. How do i achieve what i want, aka implement the automatic registration process of aquiring different classes' interface function pointers. - Assistant