hanhsh 发表于 2004-9-2 10:45:00

用vc2002定义CString出错

做一个简单的Hello World主要程序如下
void helloWorld()
{
        CString a;
        acutPrintf("\nHello World!");
}
在编译时出现“       error C2065: “CString” : 未声明的标识符 “不知道有没有人遇到过。我想CString是系统类型不应当是没加引用文件吧.

zfbj 发表于 2004-9-2 11:16:00

我还真没遇到过,把您的源文件传上来看看。

easypower 发表于 2004-9-2 12:46:00

你必须加入MFC支持,具体要包含哪个头文件和LIB我不清楚

hanhsh 发表于 2004-9-2 14:32:00

我吧文件传上来,版主帮我看一下。在HelloWorld.cpp中的26行.
void helloWorld()
{
        CString a = "Hello World!";
        acutPrintf(a);
}

hanhsh 发表于 2004-9-2 14:47:00

我怎么传不了文件呀。

hanhsh 发表于 2004-9-2 15:02:00

我是按 ObjectARX 2004\arxlabs 下的ObjectARXLabs.chm中的 step1 一步步做的只是将显示”HelloWord"部分改了。原码是
#include "stdafx.h"
#include
#include
//#include
//#include
void initApp();
void unloadApp();
void helloWorld();
void initApp()
{
// register a command with the AutoCAD command mechanism
acedRegCmds->addCommand("HELLOWORLD_COMMANDS",
"Hello",
"Bonjour",
ACRX_CMD_TRANSPARENT,
helloWorld);
}
void unloadApp()
{
acedRegCmds->removeGroup("HELLOWORLD_COMMANDS");
}
void helloWorld()
{
        CString a = "Hello World!";
        acutPrintf(a);
}
extern "C" AcRx::AppRetCode
acrxEntryPoint(AcRx::AppMsgCode msg, void* pkt)
{
switch (msg)
{
case AcRx::kInitAppMsg:
acrxDynamicLinker->unlockApplication(pkt);
acrxRegisterAppMDIAware(pkt);
initApp();
break;
case AcRx::kUnloadAppMsg:
unloadApp();
break;
default:
break;
}
return AcRx::kRetOK;
}

dipenghao 发表于 2004-9-2 20:48:00

#include

hanhsh 发表于 2004-9-2 22:32:00

to dipenghao        加了#include后出现以下错误。
d:\Program Files\Microsoft Visual Studio .NET\Vc7\atlmfc\include\afxv_w32.h(18): fatal error C1189: #error :       WINDOWS.H already included.       MFC apps must not #include
我用的是VC7.0做的一个ARX,你有遇到过吗?

easypower 发表于 2004-9-3 08:03:00

#include改成 #include

hanhsh 发表于 2004-9-3 08:21:00

TO easypower        我上边以包含 stdafx.h 了
#include "stdafx.h"
#include
#include
//#include
//#include
页: [1]
查看完整版本: 用vc2002定义CString出错