对BCB经验丰富的大虾请进!!!

freeia 2003-09-15 09:31:29
当我将程序release时,产生如下警告信息,debug下没有.
Build
[C++ Warning] ImageEx.h(58): W8027 Functions containing switch are not expanded inline
[C++ Warning] UnitMain.h(120): W8027 Functions containing switch are not expanded inline
[C++ Warning] UnitRecvMailProc.h(42): W8027 Functions containing switch are not expanded inline
[C++ Warning] UnitMain.cpp(324): W8004 'pAccountProfile' is assigned a value that is never used
[C++ Warning] UnitMain.cpp(444): W8004 'pRecvBoxProfile' is assigned a value that is never used
[C++ Warning] UnitMain.cpp(441): W8004 'pSL' is assigned a value that is never used
[C++ Warning] UnitMain.cpp(489): W8004 'pDraftBoxProfile' is assigned a value that is never used
[C++ Warning] UnitMain.cpp(486): W8004 'pSL' is assigned a value that is never used
[C++ Warning] UnitMain.cpp(534): W8004 'pSendBoxProfile' is assigned a value that is never used
[C++ Warning] UnitMain.cpp(531): W8004 'pSL' is assigned a value that is never used
[C++ Warning] UnitMain.cpp(579): W8004 'pTrashBoxProfile' is assigned a value that is never used
[C++ Warning] UnitMain.cpp(576): W8004 'pSL' is assigned a value that is never used
[C++ Warning] UnitMain.cpp(618): W8004 'pIniFile' is assigned a value that is never used
[C++ Warning] UnitMain.cpp(719): W8004 'pSL' is assigned a value that is never used
[C++ Warning] UnitMain.cpp(669): W8004 'pCharMailText' is assigned a value that is never used
[C++ Warning] AppFace.cpp(58): W8004 'pIcon' is assigned a value that is never used
[C++ Warning] ImageEx.h(58): W8027 Functions containing switch are not expanded inline
[C++ Warning] UnitMain.h(120): W8027 Functions containing switch are not expanded inline
[C++ Warning] UnitNewAccount.cpp(186): W8004 'pAccountProfile' is assigned a value that is never used
[C++ Warning] UnitRecvMailProc.h(42): W8027 Functions containing switch are not expanded inline
[C++ Warning] CommonFunc.cpp(98): W8004 'nIconIndex' is assigned a value that is never used
[C++ Warning] POP3.cpp(402): W8004 'pTempBuf' is assigned a value that is never used
[C++ Warning] POP3.cpp(472): W8004 'pTempBuf' is assigned a value that is never used
[C++ Warning] POP3.cpp(531): W8004 'pTempBuf' is assigned a value that is never used
[C++ Warning] POP3.cpp(574): W8004 'pTempBuf' is assigned a value that is never used
[C++ Warning] POP3.cpp(667): W8004 'pSL' is assigned a value that is never used
[C++ Warning] PopMail.cpp(194): W8004 'pPOP3' is assigned a value that is never used
[C++ Warning] PostMail.cpp(260): W8004 'pBuf' is assigned a value that is never used
[C++ Warning] PostMail.cpp(433): W8004 'pMemory' is assigned a value that is never used
[C++ Warning] PostMail.cpp(431): W8004 'pBuf' is assigned a value that is never used
[C++ Warning] PostMail.cpp(535): W8004 'pSmtp' is assigned a value that is never used
[C++ Warning] Base64.cpp(76): W8004 'pSrc' is assigned a value that is never used
[C++ Warning] Base64.cpp(70): W8004 'nLineLen' is assigned a value that is never used
[C++ Warning] Base64.cpp(65): W8004 'pSrc' is assigned a value that is never used
[C++ Warning] UnitRecvMailProc.h(42): W8027 Functions containing switch are not expanded inline
...全文
121 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
jishiping 2003-09-15
  • 打赏
  • 举报
回复
对于W8004 xxx is assigned a value that is never used这个警告,在编译选项里添加
-w-aus 就可以了。对于W8027 Functions containing switch are not expanded inline
这个警告,你可以先选择错误信息,然后按F1,BCB就会弹出错误,此时你就可以看到是哪
个编译选项了。

如何添加编译选项呢?执行菜单[Project]/[Edit Option Source],查找 CFLAG1 value=
所在的行,在后面的双引号内加入就可以了,多个选项之间用空格隔开。
freeia 2003-09-15
  • 打赏
  • 举报
回复
还是季大哥的话比较令人相信,同样类似的代码在VC中是没有问题的.
就是觉得编译时有警告产生不爽啊,只有
0 errors, 0 warnings.
才爽.
jishiping 2003-09-15
  • 打赏
  • 举报
回复
To ccrun(老妖):
NULL 与 0 本来就是一样的,NULL 是宏定义,本身就是0。只不过一般情况下只对指针
使用 NULL。好像HWND与void*,本身是同一类型。
jishiping 2003-09-15
  • 打赏
  • 举报
回复
上面的警告信息,分为2种。一是“变量赋值了但是没有使用”,二是“函数包含了不能被
扩展为inline的switch语句”,这2种警告都是没有任何问题的,你可以不用理会。其中的
消息映射表产生的警告“Functions containing switch are not expanded inline”,那
是BCB架构导致的,自己是不能修改去掉这个警告的。至于另外一个警告,是可以去掉的,
不过不去掉的话,也没有任何问题。

delete pAccountProfile;
pAccountProfile = 0;
在你执行完 pAccountProfile = 0; 之后,就没有再使用pAccountProfile这个变量了,或者
后面虽然又使用了,但是使用前你又对它赋值了,所以会有警告,去掉pAccountProfile=0;
这个警告就没有了。还是那句话,不去掉这行也没有关系。
ccrun.com 2003-09-15
  • 打赏
  • 举报
回复
刚看到这个:
4. delete pAccountProfile;
pAccountProfile = 0;

应该

4. delete pAccountProfile;
pAccountProfile = NULL;

这样吧。
tccsdn 2003-09-15
  • 打赏
  • 举报
回复
前面的错误应该是函数定义的不规范吧,后面的错误检查下代码尽量写规范一点,实在不行,让他报错去吧,没什么问题的
tccsdn 2003-09-15
  • 打赏
  • 举报
回复
前面的错误应该是函数定义的不是很规范,后面的错误检查下那些变量,尽量规范一点,实在不行的让它报错去吧
freeia 2003-09-15
  • 打赏
  • 举报
回复
To ccrun(老妖)(www.ccrun.com):
不是说过了吗,我一个一个查过,都使用过.
freeia 2003-09-15
  • 打赏
  • 举报
回复
指针delete后一个好习惯就是赋值为0啊,不然重复delete会导致系统collapse(夸张了一下)
ccrun.com 2003-09-15
  • 打赏
  • 举报
回复
这么多的变量赋了值但没有被使用?不会吧。
freeia 2003-09-15
  • 打赏
  • 举报
回复
To dajianshi(拔剑四顾心茫然):
问题我都使用过啊,提示的和实际的不符合啊.
佣工7001 2003-09-15
  • 打赏
  • 举报
回复
就是你符为0,引起的,不过没有关系的
freeia 2003-09-15
  • 打赏
  • 举报
回复
HICON ExtractAssociatedIconExt(HWND hWnd, AnsiString strFileName)
{
AnsiString strDefaultIcon = TEXT("");
AnsiString strShellOpenCommand = TEXT("");
AnsiString strProgramName = TEXT("");
int nIconIndex = 0;//如果注释掉这句后面代码错掉,因为后面要用到这个变量.而编译器提示 " [C++ Warning] CommonFunc.cpp(98): W8004 'nIconIndex' is assigned a value that is never used"
佣工7001 2003-09-15
  • 打赏
  • 举报
回复
这是正常的提示阿,你可以关掉的哟
#pragma argused
不过你要看看是不是真的没有使用那些变量,没用的干脆删掉!
debug状态下不是没有,你做一下build试试 :)
freeia 2003-09-15
  • 打赏
  • 举报
回复
下面我分别贴出与警告对应的代码:
1.protected:
// 自定义消息
BEGIN_MESSAGE_MAP
VCL_MESSAGE_HANDLER(CM_MOUSEENTER, TMessage, CMMouseEnter)
VCL_MESSAGE_HANDLER(CM_MOUSELEAVE, TMessage, CMMouseLeave)
END_MESSAGE_MAP(TGraphicControl)
2.
// 自定义消息映射
BEGIN_MESSAGE_MAP
VCL_MESSAGE_HANDLER(WM_GETMINMAXINFO, TWMGetMinMaxInfo, GetWindowMinMaxInfo)//控制窗口的最大最小尺寸的消息
END_MESSAGE_MAP(TForm)
3.
BEGIN_MESSAGE_MAP
VCL_MESSAGE_HANDLER(WM_MY_RECVMAIL_STATUS, TMessage, WMMyRecvMailStatus)
VCL_MESSAGE_HANDLER(WM_MY_RECVMAIL_PROGRESSBAR, TMessage, WMMyRecvMailProgressBar)
VCL_MESSAGE_HANDLER(WM_MY_RECVMAIL_PROGRESSBAR_RESET, TMessage, WMMyRecvMailProgressBarReset)
VCL_MESSAGE_HANDLER(WM_MY_RECVMAIL_ERRINFO, TMessage, WMMyRecvMailErrInfo);
VCL_MESSAGE_HANDLER(WM_MY_RECVMAIL_CLOSEFORM, TMessage, WMMyRecvMailCloseForm)
END_MESSAGE_MAP(TForm)
4. delete pAccountProfile;
pAccountProfile = 0;
5.6.7.8.等以p开头的指针变量代码同上类推,都是将指针delete pointer后,将指针赋值为零.

13,822

社区成员

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

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