I have a peculiar case where some static-initialization code in a .cpp file that is not actually used by the rest of the project seems to be excluded from the build. However, the static-initialization is important enough. Is there some way - short of making some arbitary function call into the .cpp file - to make sure that this static-initialization code gets included by the linker ? (or any pointers to why it may be excluded would be helpfull)
I have tried to expose the struct in a .h file to satisfy the linker - but this was not enough.
Using visual-studio-2017 with precompiled-headers and also cmake.
//init.cpp
#include "Pch.h"
//#pragma init_seg(lib)
struct Init {
Init(){std::cout << "in Init"<< std::endl ;}
}
Init init;