English 中文(简体)
G++没有将我的源代码编为零,而是与——O2-DNDUG一起编成,我如何解决。
原标题:G++ does not compile my source code with -O0 but it does with -O2 -DNDEBUG, how can I solve it?

我是一家ARM微观控制器的公司。 我在无动于衷的情况下建造了十字架,实际上,我的RTOS(ChibiOS)提供了简单的回忆。

我的所有代码都在C中书写,但我只使用C++与Eigen图书馆链接的一些部分除外(一个C++模版图书馆用于线阿尔盖布拉,它只是头盔)。

如果我与法国国家扫盲委员会共同汇编我的资料来源法(O2 - DNDEBUG)(只要我知道法国扫盲委员会的话,该法典就赢得了一定的需求。) 一切汇编了罚款和公司知识作品。

If I compile my source example code with -O0 I have the following:

Linking build/ch.elf
/home/noether/workspace/tool-chains/arm-none-eabi-4.6.2/lib/gcc/arm-none-eabi/4.6.2    /../../../../arm-none-eabi/lib/thumb/cortex-m4/libc.a(lib_a-abort.o): In function `abort :
/home/noether/workspace/tool-chains/summon-arm-toolchain/build/arm-none-eabi/thumb /cortex-m4/newlib/libc/stdlib/../../../../../../../gcc-4.6.2/newlib/libc/stdlib  /abort.c:63: undefined reference to `_exit 
/home/noether/workspace/tool-chains/arm-none-eabi-4.6.2/lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/lib/thumb/cortex-m4/libc.a(lib_a-signalr.o): In function `_kill_r :
/home/noether/workspace/tool-chains/summon-arm-toolchain/build/arm-none-eabi/thumb/cortex-m4/newlib/libc/reent/../../../../../../../gcc-4.6.2/newlib/libc/reent/signalr.c:61: undefined reference to `_kill 
/home/noether/workspace/tool-chains/arm-none-eabi-4.6.2/lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/lib/thumb/cortex-m4/libc.a(lib_a-signalr.o): In function `_getpid_r :
/home/noether/workspace/tool-chains/summon-arm-toolchain/build/arm-none-eabi/thumb/cortex-m4/newlib/libc/reent/../../../../../../../gcc-4.6.2/newlib/libc/reent/signalr.c:96: undefined reference to `_getpid 
collect2: ld returned 1 exit status
make: *** [build/ch.elf] Error 1

It does not matter if I put -DNDEBUG, I have the same output. I am using those flags as well, -fno-exceptions and fno-rtti. If I do not use/link the Eigen library (the only C++ stuff), g++ compiles the source fine even with -O0.

实际上,我执行了一个简单的技能——即植被和微量功能,该守则汇编了这些功能,但该法典从13KB到130KB,并坠毁(也许我没有写好这些功能)。

我想要的是,如果我使用——O0,就像用——O2做的那样,从我的法典中删除这一 st。

非常感谢。 让我知道,你们是否需要更多的信息。

问题回答

这些提法几乎肯定是由于使用<代码>assert(<>>>>>>/code(<>abort(<>>>>>/code(>)来规避程序。 显然,如果你能够进行回忆,那是可能的。

以<代码>-DNDEBUG(如选择版本中你所做的那样)为基础,将予以确定;这将造成<代码>(>assert() 宏观生成无代码,因此将不提及<代码>abort()。 选择程度本身不应改变。

或者,如果你想要维护你的断言,你就可以执行自己的<条码>(<>>>>(>>>......>宏观标准,而这种宏观方法确实需要任何回忆。

你们可以简单地为那些失踪的传闻者实施 st,并将其与你的法典联系起来。 这将使联系人保持平静,但你可能会使这些障碍变得敏感或有用。 离开()可能无限期地断断断裂和 lo,或强迫重新set。 • 技能(技能)可能 h在你的RTOS中,以终止胎面,或简单地叫 _-exit(),而_getpid()可能回去某些 du价值或RTOS的透镜。





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签