我正在使用/ NODEFAULTLIB禁用CRT(C运行时),但是未调用我的构造函数,这最终在std :: map(访问冲突)中导致错误,因为自std ::起未正确初始化地图构造函数没有被调用。
使用LLVM 8.0.0编译的代码,以调试模式x86编译
class c_test
{
public:
c_test( int a ) // Constructor not called
{
printf( "Test: %i\n", a ); // Doesn't appear and breakpoint is not reached
}
void add( const std::string& key, const std::string& val )
{
_data[ key ] = val;
}
private:
std::map< std::string, std::string > _data;
};
c_test test{ 1337 };
int main()
{
test.add( "qwrqrqr", "23142421" );
test.add( "awrqw", "12asa1faf" );
return 1;
}
我已经实现了自己的函数new(HeapAlloc),delete(HeapFree),printf,memcpy,memmove等,并且都运行良好,我不知道为什么会这样。