{$L xxx.obj}为什么不能是cpp编译的obj,只能是c编译的obj?

makefool 2004-12-18 05:31:15
delphi的unit "use_c.pas"源代码:
{*****************************************************}
unit use_c;
interface
implementation

function GetGlobalValue: integer;
stdcall;
external;
{$L cuse.obj}

end.
{*****************************************************}

cpp文件"cuse.cpp"的源代码:
{*****************************************************}
int iGlobal = 0;
extern "C" int _stdcall GetGlobalValue(void)
{return iGlobal;}
{*****************************************************}


delphi版本7.0,c++编译器为bcc32 5.5.1(borland的freecommandtool)
命令行为
bcc32 -c cuse.cpp
delphi报Unsatisfied forward or external declaration: 'GetGlobalValue'的错
如果把cuse.cpp名字换成cuse.c
bcc32 -c cuse.c
delphi就能编译成功

tdump两个obj文件可以发现
1、使用cpp为的编译结果是
0000A7 COMDEF
Name: 1: 'GetGlobalValue' virtual(_TEXT) Length: 000a bytes
0000BD PUBDEF '_iGlobal' Segment: _DATA:0000
2、使用cpp为的编译结果是
0000A1 PUBDEF '_iGlobal' Segment: _DATA:0000
0000B3 PUBDEF 'GetGlobalValue' Segment: _TEXT:0000

这个就搞不懂了,尝试了bcc32的多个编译选项,依然不能成功。

关键的希望能用cpp编译的obj
...全文
114 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
yxf 2004-12-19
  • 打赏
  • 举报
回复
Mark

这里是公共机房,回去再帮你看。

makefool 2004-12-19
  • 打赏
  • 举报
回复
新的发现,换了bcc 5.02编译cpp文件居然能用delphi联接了。
同是borland的产品,为何如此?

提问了2天,回复为0,让人郁闷。

16,748

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 语言基础/算法/系统设计
社区管理员
  • 语言基础/算法/系统设计社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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