为什么我的C++Builder不能#include

kevincsdn 2003-06-03 11:09:41
为什么我的C++Builder不能#include <shlobj.h>?

编译时,会和shobjdl.h出现冲突,多重声明。
...全文
121 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
kevincsdn 2003-06-04
  • 打赏
  • 举报
回复
从理论上来说,#include <shlobj.h>不用放在cpp文件最前面,可以放在头文件里。

经我多次验证,只要在#include <vcl.h>之前#define NO_WIN32_LEAN_AND_MEAN 即可。

<vcl.h>是在cpp文件包含的,而且在Unit.h之前,所以#define NO_WIN32_LEAN_AND_MEAN不能在头文件中定义。而#include <shlobj.h>完全可以放在头文件中。

完美解决,结分!
Behard 2003-06-04
  • 打赏
  • 举报
回复
看看 精华区 和 FAQ
zywx 2003-06-03
  • 打赏
  • 举报
回复
不好意思,都要放到cpp文件的最前面,不能放到头文件里
zywx 2003-06-03
  • 打赏
  • 举报
回复
还有把#include <shlobj.h>也要放到最前面
zywx 2003-06-03
  • 打赏
  • 举报
回复
记住要放到
#include <shlobj.h>的前面
kevincsdn 2003-06-03
  • 打赏
  • 举报
回复
我包含的头文件如下:
#ifndef Unit1H
#define Unit1H
#define NO_WIN32_LEAN_AND_MEAN
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ComCtrls.hpp>
#include <ToolWin.hpp>
#include <ExtCtrls.hpp>
#include <IdBaseComponent.hpp>
#include <IdComponent.hpp>
#include <IdFTP.hpp>
#include <IdTCPClient.hpp>
#include <IdTCPConnection.hpp>
#include <IdIntercept.hpp>
#include <IdAntiFreeze.hpp>
#include <IdAntiFreezeBase.hpp>
#include "IdLogEvent.hpp"
#include <IdLogBase.hpp>
#include <ImgList.hpp>
#include "PERFGRAP.h"
#include <Buttons.hpp>
#include "trayicon.h"
#include <shlobj.h>
kingcaiyao 2003-06-03
  • 打赏
  • 举报
回复
#define NO_WIN32_LEAD_AND_MEAN
#include "shlobj.h"
zywx 2003-06-03
  • 打赏
  • 举报
回复
怎么会没用呢
一般还要包含
#include <ComObj.hpp>

kevincsdn 2003-06-03
  • 打赏
  • 举报
回复
错了,不是和shobjdl.h冲突,错误提示如下:
Build
[C++ Error] shobjidl.h(2193): E2238 Multiple declaration for 'FOLDERSETTINGS'
[C++ Error] shobjidl.h(8095): E2238 Multiple declaration for 'DESKBANDINFO'
[C++ Error] shlobj.h(1422): E2238 Multiple declaration for 'FVSHOWINFO'
[C++ Error] shlobj.h(3457): E2238 Multiple declaration for 'SHELLFLAGSTATE'
[C++ Warning] Unit1.cpp(88): W8070 Function should return a value
kevincsdn 2003-06-03
  • 打赏
  • 举报
回复
没用啊。
zywx 2003-06-03
  • 打赏
  • 举报
回复
在最前面加上
#define NO_WIN32_LEAN_AND_MEAN // 调用SHELL API 需包含的

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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