CString不能用

thebestone111 2005-12-03 03:14:30
我建了一个win32 DLL
在一个文件中我用到了CString形的数据,编译老是提示我出错
#ifndef __PUBLICSOURCE__
#define __PUBLICSOURCE__

#include "stdafx.h"

/*
描述:常用公共函数类
*/
class Tpublicsource
{
public:
CString bytetostr(BYTE value);
// int HexToBuf(char *buf,int len);


};

#endif
--------------------Configuration: Dll_VC - Win32 Debug--------------------
Compiling...
publicsource.cpp
d:\xj_work_station\test\1203\002\dll_vc\publicsource.h(12) : error C2146: syntax error : missing ';' before identifier 'BYTE2Str'
d:\xj_work_station\test\1203\002\dll_vc\publicsource.h(12) : error C2501: 'CString' : missing storage-class or type specifiers
执行 cl.exe 时出错.
Creating browse info file...

Dll_VC.dll - 1 error(s), 0 warning(s)
...全文
253 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
mfkzj 2005-12-05
  • 打赏
  • 举报
回复
MFC apps must not #include <windows.h>

你在stdafx.h文件里面删除 windows.h 就可以了
hjcy_2002 2005-12-05
  • 打赏
  • 举报
回复
#include <afx.h>
加入了这个就可以用CString类型了
cannot open file '.\Debug\publicsource.sbr': No such file or directory
这个问题只需要Build->Rebuild All
thebestone111 2005-12-05
  • 打赏
  • 举报
回复
我没有手工包含<windows.h>,要在那里去
thebestone111 2005-12-05
  • 打赏
  • 举报
回复
我照着做了,可以编译如下

--------------------Configuration: Dll_VC - Win32 Debug--------------------
Linking...
nafxcwd.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in Dll_VC.obj
Debug/Dll_VC.dll : fatal error LNK1169: one or more multiply defined symbols found
执行 link.exe 时出错.

Dll_VC.dll - 1 error(s), 0 warning(s)
DrSmart 2005-12-03
  • 打赏
  • 举报
回复
同意
oyljerry 2005-12-03
  • 打赏
  • 举报
回复
<windows.h>就不需要包含了
rebuild all
thebestone111 2005-12-03
  • 打赏
  • 举报
回复
我做了,但編译如下
--------------------Configuration: Dll_VC - Win32 Debug--------------------
Compiling...
publicsource.cpp
d:\program files\microsoft visual studio\vc98\mfc\include\afxv_w32.h(14) : fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include <windows.h>
执行 cl.exe 时出错.
Creating browse info file...
BSCMAKE: error BK1506 : cannot open file '.\Debug\publicsource.sbr': No such file or directory
执行 bscmake.exe 时出错.

Dll_VC.dll - 1 error(s), 0 warning(s)
CodeProject-Jerry 2005-12-03
  • 打赏
  • 举报
回复
#include <afx.h>

16,551

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Creator Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧