C/C++编程中遇到的错误

C/C++编程中遇到的错误(1)  

2008-10-08 16:50:57|  分类: General|字号 订阅

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)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值