【发布时间】:2011-10-08 05:36:13
【问题描述】:
//head.h//
extern int sum(int,int);
//head.cpp//
#include "head.h"
#include "stdafx.h"
int sum(int x, int y)
{
return (x+y);
}
//mainfn.cpp//
#include "head.h"
#include "stdafx.h"
#include string
#include iostream
#include stdio.h
using std::string;
using std::cout;
using namespace System;
int main()
{
int x=10,y=2;
printf("value: %d",sum(x,y));
Console::ReadLine();
return 0;
}
在 Visual Studio 2005 中构建时,此 vc++ 项目出现以下错误:
error C3861: 'sum': identifier not found.
谁能帮我解决这个问题?
【问题讨论】:
-
stdafx.h 中有什么,您的预编译头设置是什么?也许你对预编译的头文件有一些奇怪的事情,因为发布的代码没有问题。
-
实际上当我在visual studio中启动新的VC++项目时,总是包含这个预编译的头文件。
标签: c++ visual-c++ stdafx.h