【发布时间】:2014-01-22 22:44:54
【问题描述】:
当我在 Ubuntu(Ubuntu 13.10,64 位,g++ 4.8.1)中运行这个简单的代码时:
#include <iostream>
#include <typeinfo>
#include <string>
using namespace std;
int main(void)
{
const type_info &ti_trait = typeid(char_traits<char>::char_type);
cout << "Traits character type name : " <<
ti_trait.name() << endl;
return 0;
}
一切正常,但在 Windows(Windows 8 64 位、mingw、g++ 4.8.1)中,我得到“程序已停止工作”(编译工作正常且 -Wall 不产生警告)。
在 Visual Studio 中编译和执行的相同代码可以正常工作。
有什么想法吗?
【问题讨论】:
-
您确定是因为对
name的调用导致它失败了吗? -
@sftrabbit 是的,但我不明白为什么......
-
奇怪的是,问题来自endl。如果我删除它,程序可以正常运行!?
-
64 位 Windows? Have you had a look at this?
-
这解决了问题!我必须用“-static-libgcc -static-libstdc++”编译。感谢您的宝贵时间!
标签: c++ windows-8 mingw typeid ubuntu-13.10