1.C++程序中出现 fatal error C1189: #error : eh.h is only for C++!
in creating dynamic dll vc++ 6.0:
added some .h and .c files to it.
i get:
fatal error C1189: #error : \"eh.h is only for C++!\"
#ifndef __cplusplus
#error \"eh.h is only for C++!\"
#endif
The cause :
include a C++ header file in a .c file.
for example: In a.c, you included <iostream>
2.System : 具有该名称的命名空间不存在
请问这个程序编译为何报错:
#include "stdafx.h"
using namespace System;
int _tmain(int argc, _TCHAR* argv[])
{
Console::WriteLine ("TEST");
return 0;
}
错误是:error C2871: “System”: 具有该名称的命名空间不存在
error C2653: “Console”: 不是类或命名空间名称
error C3861: “WriteLine”: 找不到标识符
原因:这些命名空间的声明在.Net的DLL里面,非CLR模板创建的工程需要在项目属性中手动添加引用。
Project->Win32project Property Pages->Configuration Properties->General
Common Language Runtime support 填Common Language Runtime Support(/clr)