如何禁用 borland c++ 中的异常处理代码5.5 编译器
抱歉我的英语很弱,
我正在使用 borland c++ 5.5 编译器,我喜欢它,但是 有时有一个问题让我担心;我正在写纯c 应用程序没有这样一个 C++“功能”,但我 使用 -P 开关编译以强制“c++ 编译”,因为 如果我在 c 模式下编译,我必须声明“int i” 在 for 循环之前,这是愚蠢的。所以我用c++编译 模式,但我担心自己这会让 编译器放置一些异常处理代码 进入我的应用程序 - 当我查看我的程序时 使用十六进制编辑器我看到很多奇怪的字符串 可能与.exe中的异常处理有关; 当我使用 -x- 切换到我的应用程序时,它会带来 没有效果。我什至可以提供我的 progs exe 的链接
dl.dropbox.com/u/42887985/unpack%20aeroplane.zip
如何确保没有异常处理 (并且 exe 中没有任何其他不必要的东西,因为 我更喜欢保持它很小)里面有吗?
非常感谢这个问题的答案,这很重要 对我来说,冷杉
Sorry for my weak english
I'm using borland c++ 5.5 compiler and i like it but
one question worries me sometimes; I am writing pure c
applications with not such one c++ 'feature', but i
compile with -P switch to force 'c++ compile' because
if I compile in c-mode I have to declare "int i"
before for loop and it is stupid. So I compile in c++
mode but I am worrying myself that that it makes
compiler to put some exception handling code
into my applications - when i look into my prog
with hex editor i see a lot of strange strings
possibly related to exception handling in .exe;
when i use -x- switch to my application it brings
no effect. I can even give a link to my progs exe
dl.dropbox.com/u/42887985/unpack%20aeroplane.zip
How can I make sure that no exception handling
(and no any other unnecessary stuff in exe becouse
i prefer to keep it tiny) is present inside?
wery much tnx for answer to that, it is important
for me, fir
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果不支持作为标准一部分的异常,就不可能有 C++。我不能说它是否对您的可执行文件有很大影响。
如果我是你,我会得到一个更现代的 C 编译器。在 Windows 上你应该尝试 mingw。使用 C99,您可以在任何您喜欢的地方声明变量。 Borland 编译器很古老。
You can't have C++ without support for exceptions which is part of the standard. Whether or not it has much impact on you executable I cannot say.
I'd get a more modern C compiler if I were you. On Windows you should try mingw. With C99 you can declare variables wherever you like. That Borland compiler is ancient.
正如所注意到的,您不能从 C++ 库中排除异常处理。但还有一些其他编译器选项和其他技巧,可以帮助您减少代码大小
typeid
和dynamic_cast< /code> 如果您不使用任何 C++ 可能性,您可以安全地关闭此选项(在循环内定义变量并不重要:-)),这可能会稍微减少您的可执行文件大小。 RTTI 选项默认启用,您可以使用 -RT- 开关切换它。
As it was noticed, you can't exclude exception handling from C++ library. But there are also some other compiler options and other tricks, which could help you to reduce code size
typeid
anddynamic_cast
You can safely turn of this option if you don't use any of C++ possibilities, (defining variables inside of loops doensn't matter :-)), this could slightly reduce your executable size. RTTI Option is enabled by default and you can switch it of using -RT- switch__pascal
keyword in function definition or by providing -p switch to compiler