gcc 相关问题

GCC是GNU编译器集合。它是Linux上事实上的标准C编译器,也支持许多其他语言和平台。

GCC 和 Visual Studio 上的不同输出

我尝试在 CPP 中编写一个程序,它获取一个中缀表达式,将其转换为后缀表达式,然后使用我执行的堆栈类来计算该表达式。 我以为我写的东西...

回答 1 投票 0

如何在GCC中打印/转换十进制浮点值?

GCC 文档描述了最近 GCC 中有限的十进制浮点支持。 但我该如何实际使用它呢? 例如,在 Fedora 18、GCC 4.7.2 上。 一个简单的 C 程序,例如 int main() { _十进制 64 x...

回答 1 投票 0

当唯一成员是位字段时,__attribute__ ((packed)) 可以创建 1 位结构吗?

我正在阅读 GNU/GCC 的文档,停在了 __attribute__ ((packed)) 的描述处。 它说: 包装的 Packed 属性指定变量或结构体字段...

回答 1 投票 0

Fortran real(REAL80) 和 C __float80 大小

考虑以下 C 代码: #包括 #包括 int main() { int16_t i16; __float80 r80; printf("16位整数的大小: %u 80 位实数的大小:%u\...

回答 1 投票 0

KDevelop 找不到简单的 C++ 包含文件

我是 KDevelop 的新手。 我正在尝试构建一个以以下内容开头的 C++ 程序 #包括 但它找不到它。 该标头位于 /usr/包括 GCC 应该看看这个

回答 1 投票 0

使用 gdb 调试时无法从外部文件加载调试符号

我正在研究如何使用 gdb 来调试外部文件中的符号。 我构建了一个依赖于 og 和同样小的共享 libaray 的小型可执行文件。 我用 cmake producin 构建了可执行文件...

回答 1 投票 0

错误:条件表达式中指针/整数类型不匹配

我有这个代码: #包括 #包括 /* 如果 ?: 的 if-true 或 if-false 表达式中的任何一个为 void *,则 * 结果也应为 void *(加上 const if

回答 1 投票 0

C 类函数宏中的静态断言

如何在类似函数的宏中实现(编译时)静态断言? 对于将静态断言作为“C”语句注入的情况,有很好的讨论和很多替代方案 -

回答 1 投票 0

追踪硬件相关的数字差异直至指令

我已经使用 GCC 将 C 数值仿真模型编译为 ELF 二进制文件(文件扩展名为 .mexa64 的共享对象,因为已加载到 MATLAB 中)。它没有使用调试或优化标志。它你...

回答 1 投票 0

尽管编译了正确的架构,但为什么我会收到“执行二进制文件时出错”?

我正在尝试使用 gcc 和 gfortran for aarch64 编译 C/Fortran 程序。 尽管成功完成编译,但我无法执行二进制文件:我得到 bash: .: gMultiwfn: 无法执行二进制文件...

回答 1 投票 0

LITTLE_ENDIAN、BIG_ENDIAN 和 BYTE_ORDER 宏应该会用 GCC 污染我的全局命名空间吗?

我上过这样的课: 字节顺序类 {民众: 枚举类 ByteOrderEnum : unsigned char { BIG_ENDIAN = 0, LITTLE_ENDIAN = 1 }; //^^^ 错误:数字常量之前的预期标识符 ...

回答 1 投票 0

这个函数的汇编是如何实现条件的?

以下代码, int foo(int); int 栏(int); int foobar(int i) { int a = foo(i); int b = 条(i); 返回a==b?甲:乙; }; 使用 GCC trunk 正在编译此程序集: foobar(int)...

回答 2 投票 0

静态库的部分被更改,原因不明

我使用的是arm-none-eabi-gcc (V6.3),CPU核心是ARM COrtexM0。 在我的链接器文件中,我为文本和rodata 创建了 2 个部分。 .text 部分适用于所有 C 代码文本和rodata,除了

回答 1 投票 0

-通过引用为 unordered_map 迭代器构造 Wrange-loop?

这是一个简单的for循环: unsigned_map 地图 = ...; for (pair const &kv : 地图) { ... } GCC 对此发出警告,它说我正在制作副本...... 源/

回答 2 投票 0

GCC 和 Visual Studio(CPP、C++)上的不同输出

我尝试在 CPP 中编写一个程序,它获取一个中缀表达式,将其转换为后缀表达式,然后使用我执行的堆栈类来计算该表达式。 我以为我写的东西...

回答 1 投票 0

collect2.exe:错误:ld 返回 116 退出状态

windows 10,gcc是通过msys2安装的,路径:“C:\msys64\ucrt64 in”。 使用 g++ 编译时,出现错误“collect2.exe : error: ld returned 116 exit status.”, 示例:g++。/

回答 1 投票 0

typedef 定长数组

我必须定义一个24位数据类型。我使用char[3]来表示类型。我可以将 typedef char[3] 转换为 type24 吗?我在代码示例中尝试过。我把 typedef char[3] type24;在我的头文件中。比较...

回答 8 投票 0

ThreadSanitizer:使用 std::condition_variable::wait_for

GCC 线程清理程序报告“互斥体的双重锁定”警告,代码如下: #包括 #包括 #包括 #包括 GCC 线程清理程序报告“互斥锁双重锁定”警告,代码如下: #include <mutex> #include <condition_variable> #include <chrono> #include <stop_token> #include <thread> template<typename Rep, typename Period> void sleep_for(const std::chrono::duration<Rep, Period>& d, const std::stop_token& token) { std::mutex mutex; std::unique_lock<std::mutex> lock{ mutex }; std::condition_variable_any().wait_for(lock, token, d, [&token] { return false; }); } int main() { std::jthread watch_dog_thread([](std::stop_token token) { sleep_for(std::chrono::seconds(std::chrono::seconds(3)), token); }); std::this_thread::sleep_for(std::chrono::seconds(1)); return 0; } GCC 消毒剂输出: ================== WARNING: ThreadSanitizer: double lock of a mutex (pid=6767) #0 pthread_mutex_lock ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:4250 (libtsan.so.0+0x53908) #1 __gthread_mutex_lock /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:749 (MyAppTest+0x83c54) #2 std::mutex::lock() /usr/include/c++/11/bits/std_mutex.h:100 (MyAppTest+0x83fd2) #3 std::lock_guard<std::mutex>::lock_guard(std::mutex&) /usr/include/c++/11/bits/std_mutex.h:229 (MyAppTest+0x86974) #4 std::_V2::condition_variable_any::notify_all() /usr/include/c++/11/condition_variable:299 (MyAppTest+0x857f6) #5 operator() /usr/include/c++/11/condition_variable:404 (MyAppTest+0x2d9556) #6 _S_execute /usr/include/c++/11/stop_token:638 (MyAppTest+0x2d9d19) #7 std::stop_token::_Stop_cb::_M_run() /usr/include/c++/11/stop_token:148 (MyAppTest+0x849fd) #8 std::stop_token::_Stop_state_t::_M_request_stop() /usr/include/c++/11/stop_token:256 (MyAppTest+0x84d2a) #9 std::stop_source::request_stop() const /usr/include/c++/11/stop_token:536 (MyAppTest+0x8550c) #10 std::jthread::request_stop() /usr/include/c++/11/thread:201 (MyAppTest+0x856a6) #11 std::jthread::~jthread() /usr/include/c++/11/thread:129 (MyAppTest+0x8555b) #12 main /home/def/repos/MyApp/Tests/main.cpp:38 (MyAppTest+0x2d90c1) Location is heap block of size 56 at 0x7b1000002000 allocated by thread T1: #0 operator new(unsigned long) ../../../../src/libsanitizer/tsan/tsan_new_delete.cpp:64 (libtsan.so.0+0x8f542) #1 __gnu_cxx::new_allocator<std::_Sp_counted_ptr_inplace<std::mutex, std::allocator<std::mutex>, (__gnu_cxx::_Lock_policy)2> >::allocate(unsigned long, void const*) /usr/include/c++/11/ext/new_allocator.h:121 (MyAppTest+0x8b350) #2 std::allocator<std::_Sp_counted_ptr_inplace<std::mutex, std::allocator<std::mutex>, (__gnu_cxx::_Lock_policy)2> >::allocate(unsigned long) /usr/include/c++/11/bits/allocator.h:173 (MyAppTest+0x8af4f) #3 std::allocator_traits<std::allocator<std::_Sp_counted_ptr_inplace<std::mutex, std::allocator<std::mutex>, (__gnu_cxx::_Lock_policy)2> > >::allocate(std::allocator<std::_Sp_counted_ptr_inplace<std::mutex, std::allocator<std::mutex>, (__gnu_cxx::_Lock_policy)2> >&, unsigned long) /usr/include/c++/11/bits/alloc_traits.h:460 (MyAppTest+0x8af4f) #4 std::__allocated_ptr<std::allocator<std::_Sp_counted_ptr_inplace<std::mutex, std::allocator<std::mutex>, (__gnu_cxx::_Lock_policy)2> > > std::__allocate_guarded<std::allocator<std::_Sp_counted_ptr_inplace<std::mutex, std::allocator<std::mutex>, (__gnu_cxx::_Lock_policy)2> > >(std::allocator<std::_Sp_counted_ptr_inplace<std::mutex, std::allocator<std::mutex>, (__gnu_cxx::_Lock_policy)2> >&) /usr/include/c++/11/bits/allocated_ptr.h:97 (MyAppTest+0x8a96e) #5 std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<std::mutex, std::allocator<std::mutex>>(std::mutex*&, std::_Sp_alloc_shared_tag<std::allocator<std::mutex> >) /usr/include/c++/11/bits/shared_ptr_base.h:648 (MyAppTest+0x8a1d9) #6 std::__shared_ptr<std::mutex, (__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocator<std::mutex>>(std::_Sp_alloc_shared_tag<std::allocator<std::mutex> >) /usr/include/c++/11/bits/shared_ptr_base.h:1337 (MyAppTest+0x8996e) #7 std::shared_ptr<std::mutex>::shared_ptr<std::allocator<std::mutex>>(std::_Sp_alloc_shared_tag<std::allocator<std::mutex> >) /usr/include/c++/11/bits/shared_ptr.h:409 (MyAppTest+0x88b8d) #8 std::shared_ptr<std::mutex> std::allocate_shared<std::mutex, std::allocator<std::mutex>>(std::allocator<std::mutex> const&) /usr/include/c++/11/bits/shared_ptr.h:861 (MyAppTest+0x87c56) #9 std::shared_ptr<std::mutex> std::make_shared<std::mutex>() /usr/include/c++/11/bits/shared_ptr.h:877 (MyAppTest+0x8688f) #10 std::_V2::condition_variable_any::condition_variable_any() /usr/include/c++/11/condition_variable:283 (MyAppTest+0x85763) #11 sleep_for<long int, std::ratio<1> > /home/def/repos/MyApp/Tests/main.cpp:21 (MyAppTest+0x2d91c0) #12 operator() /home/def/repos/MyApp/Tests/main.cpp:32 (MyAppTest+0x2d9016) #13 __invoke_impl<void, main()::<lambda(std::stop_token)>, std::stop_token> /usr/include/c++/11/bits/invoke.h:61 (MyAppTest+0x2da0db) #14 __invoke<main()::<lambda(std::stop_token)>, std::stop_token> /usr/include/c++/11/bits/invoke.h:96 (MyAppTest+0x2d9fd2) #15 _M_invoke<0, 1> /usr/include/c++/11/bits/std_thread.h:253 (MyAppTest+0x2d9ede) #16 operator() /usr/include/c++/11/bits/std_thread.h:260 (MyAppTest+0x2d9e6a) #17 _M_run /usr/include/c++/11/bits/std_thread.h:211 (MyAppTest+0x2d9e20) #18 <null> <null> (libstdc++.so.6+0xda6b3) Mutex M51 (0x7b1000002010) created at: #0 pthread_mutex_lock ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:4250 (libtsan.so.0+0x53908) #1 __gthread_mutex_lock /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:749 (MyAppTest+0x83c54) #2 std::mutex::lock() /usr/include/c++/11/bits/std_mutex.h:100 (MyAppTest+0x83fd2) #3 std::unique_lock<std::mutex>::lock() /usr/include/c++/11/bits/unique_lock.h:139 (MyAppTest+0x87e19) #4 std::unique_lock<std::mutex>::unique_lock(std::mutex&) /usr/include/c++/11/bits/unique_lock.h:69 (MyAppTest+0x86c78) #5 wait_until<std::unique_lock<std::mutex>, std::chrono::_V2::steady_clock, std::chrono::duration<long int, std::ratio<1, 1000000000> >, (anonymous namespace)::sleep_for<long int, std::ratio<1> >(const std::chrono::duration<long int>&, const std::stop_token&)::<lambda()> > /usr/include/c++/11/condition_variable:410 (MyAppTest+0x2d9642) #6 wait_for<std::unique_lock<std::mutex>, long int, std::ratio<1>, (anonymous namespace)::sleep_for<long int, std::ratio<1> >(const std::chrono::duration<long int>&, const std::stop_token&)::<lambda()> > /usr/include/c++/11/condition_variable:435 (MyAppTest+0x2d93ef) #7 sleep_for<long int, std::ratio<1> > /home/def/repos/MyApp/Tests/main.cpp:21 (MyAppTest+0x2d9204) #8 operator() /home/def/repos/MyApp/Tests/main.cpp:32 (MyAppTest+0x2d9016) #9 __invoke_impl<void, main()::<lambda(std::stop_token)>, std::stop_token> /usr/include/c++/11/bits/invoke.h:61 (MyAppTest+0x2da0db) #10 __invoke<main()::<lambda(std::stop_token)>, std::stop_token> /usr/include/c++/11/bits/invoke.h:96 (MyAppTest+0x2d9fd2) #11 _M_invoke<0, 1> /usr/include/c++/11/bits/std_thread.h:253 (MyAppTest+0x2d9ede) #12 operator() /usr/include/c++/11/bits/std_thread.h:260 (MyAppTest+0x2d9e6a) #13 _M_run /usr/include/c++/11/bits/std_thread.h:211 (MyAppTest+0x2d9e20) #14 <null> <null> (libstdc++.so.6+0xda6b3) Thread T1 (tid=6769, running) created by main thread at: #0 pthread_create ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:969 (libtsan.so.0+0x605f8) #1 std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)()) <null> (libstdc++.so.6+0xda989) #2 _S_create<main()::<lambda(std::stop_token)> > /usr/include/c++/11/thread:217 (MyAppTest+0x2d94c0) #3 jthread<main()::<lambda(std::stop_token)> > /usr/include/c++/11/thread:118 (MyAppTest+0x2d9301) #4 main /home/def/repos/MyApp/Tests/main.cpp:33 (MyAppTest+0x2d908a) SUMMARY: ThreadSanitizer: double lock of a mutex /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:749 in __gthread_mutex_lock ================== ================== WARNING: ThreadSanitizer: lock-order-inversion (potential deadlock) (pid=6767) Cycle in lock order graph: M48 (0x7fa6e2e9ece0) => M51 (0x7b1000002010) => M48 Mutex M51 acquired here while holding mutex M48 in thread T1: #0 pthread_mutex_lock ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:4250 (libtsan.so.0+0x53908) #1 __gthread_mutex_lock /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:749 (MyAppTest+0x83c54) #2 std::mutex::lock() /usr/include/c++/11/bits/std_mutex.h:100 (MyAppTest+0x83fd2) #3 std::unique_lock<std::mutex>::lock() /usr/include/c++/11/bits/unique_lock.h:139 (MyAppTest+0x87e19) #4 std::unique_lock<std::mutex>::unique_lock(std::mutex&) /usr/include/c++/11/bits/unique_lock.h:69 (MyAppTest+0x86c78) #5 wait_until<std::unique_lock<std::mutex>, std::chrono::_V2::steady_clock, std::chrono::duration<long int, std::ratio<1, 1000000000> >, (anonymous namespace)::sleep_for<long int, std::ratio<1> >(const std::chrono::duration<long int>&, const std::stop_token&)::<lambda()> > /usr/include/c++/11/condition_variable:410 (MyAppTest+0x2d9642) #6 wait_for<std::unique_lock<std::mutex>, long int, std::ratio<1>, (anonymous namespace)::sleep_for<long int, std::ratio<1> >(const std::chrono::duration<long int>&, const std::stop_token&)::<lambda()> > /usr/include/c++/11/condition_variable:435 (MyAppTest+0x2d93ef) #7 sleep_for<long int, std::ratio<1> > /home/def/repos/MyApp/Tests/main.cpp:21 (MyAppTest+0x2d9204) #8 operator() /home/def/repos/MyApp/Tests/main.cpp:32 (MyAppTest+0x2d9016) #9 __invoke_impl<void, main()::<lambda(std::stop_token)>, std::stop_token> /usr/include/c++/11/bits/invoke.h:61 (MyAppTest+0x2da0db) #10 __invoke<main()::<lambda(std::stop_token)>, std::stop_token> /usr/include/c++/11/bits/invoke.h:96 (MyAppTest+0x2d9fd2) #11 _M_invoke<0, 1> /usr/include/c++/11/bits/std_thread.h:253 (MyAppTest+0x2d9ede) #12 operator() /usr/include/c++/11/bits/std_thread.h:260 (MyAppTest+0x2d9e6a) #13 _M_run /usr/include/c++/11/bits/std_thread.h:211 (MyAppTest+0x2d9e20) #14 <null> <null> (libstdc++.so.6+0xda6b3) Hint: use TSAN_OPTIONS=second_deadlock_stack=1 to get more informative warning message Mutex M48 acquired here while holding mutex M51 in thread T1: #0 pthread_mutex_lock ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:4250 (libtsan.so.0+0x53908) #1 __gthread_mutex_lock /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:749 (MyAppTest+0x83c54) #2 std::mutex::lock() /usr/include/c++/11/bits/std_mutex.h:100 (MyAppTest+0x83fd2) #3 std::unique_lock<std::mutex>::lock() /usr/include/c++/11/bits/unique_lock.h:139 (MyAppTest+0x87e19) #4 std::_V2::condition_variable_any::_Unlock<std::unique_lock<std::mutex> >::~_Unlock() /usr/include/c++/11/condition_variable:272 (MyAppTest+0x888a5) #5 wait_until<std::unique_lock<std::mutex>, std::chrono::_V2::steady_clock, std::chrono::duration<long int, std::ratio<1, 1000000000> >, (anonymous namespace)::sleep_for<long int, std::ratio<1> >(const std::chrono::duration<long int>&, const std::stop_token&)::<lambda()> > /usr/include/c++/11/condition_variable:419 (MyAppTest+0x2d9708) #6 wait_for<std::unique_lock<std::mutex>, long int, std::ratio<1>, (anonymous namespace)::sleep_for<long int, std::ratio<1> >(const std::chrono::duration<long int>&, const std::stop_token&)::<lambda()> > /usr/include/c++/11/condition_variable:435 (MyAppTest+0x2d93ef) #7 sleep_for<long int, std::ratio<1> > /home/def/repos/MyApp/Tests/main.cpp:21 (MyAppTest+0x2d9204) #8 operator() /home/def/repos/MyApp/Tests/main.cpp:32 (MyAppTest+0x2d9016) #9 __invoke_impl<void, main()::<lambda(std::stop_token)>, std::stop_token> /usr/include/c++/11/bits/invoke.h:61 (MyAppTest+0x2da0db) #10 __invoke<main()::<lambda(std::stop_token)>, std::stop_token> /usr/include/c++/11/bits/invoke.h:96 (MyAppTest+0x2d9fd2) #11 _M_invoke<0, 1> /usr/include/c++/11/bits/std_thread.h:253 (MyAppTest+0x2d9ede) #12 operator() /usr/include/c++/11/bits/std_thread.h:260 (MyAppTest+0x2d9e6a) #13 _M_run /usr/include/c++/11/bits/std_thread.h:211 (MyAppTest+0x2d9e20) #14 <null> <null> (libstdc++.so.6+0xda6b3) Thread T1 (tid=6769, running) created by main thread at: #0 pthread_create ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:969 (libtsan.so.0+0x605f8) #1 std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)()) <null> (libstdc++.so.6+0xda989) #2 _S_create<main()::<lambda(std::stop_token)> > /usr/include/c++/11/thread:217 (MyAppTest+0x2d94c0) #3 jthread<main()::<lambda(std::stop_token)> > /usr/include/c++/11/thread:118 (MyAppTest+0x2d9301) #4 main /home/def/repos/MyApp/Tests/main.cpp:33 (MyAppTest+0x2d908a) SUMMARY: ThreadSanitizer: lock-order-inversion (potential deadlock) /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:749 in __gthread_mutex_lock ================== ThreadSanitizer: reported 2 warnings 但是如果我用这个替换 sleep_for 函数: template<typename Rep, typename Period> void sleep_for(const std::chrono::duration<Rep, Period>& d, const std::stop_token& token) { std::mutex mutex; std::unique_lock<std::mutex> lock{ mutex }; std::condition_variable cv; std::stop_callback stop_wait { token, [&cv]() { cv.notify_one(); } }; cv.wait_for(lock, d, [&token]() { return token.stop_requested(); }); } GCC 线程清理程序停止报告错误。 有什么区别? 我不确定第一个版本中的 lambda 是否应该返回 false 或 token.stop_requested(),但这两种选择都有相同的错误。 看起来这是 gcc 中的一个错误(我在评论中提到的one)。当使用 wait_for() 并且另一个线程尝试锁定同一个互斥体时,它会触发“双重锁定”警告。一个简化的例子: #include <chrono> #include <condition_variable> #include <mutex> #include <thread> using namespace std::chrono_literals; std::mutex mtx; std::condition_variable cv; void run1() { std::unique_lock lck{mtx}; cv.wait_for(lck, 1s); } void run2() { std::unique_lock lck{mtx}; std::this_thread::sleep_for(500ms); cv.notify_all(); } int main() { std::jthread th1{ run1 }; std::jthread th2{ run2 }; } 它在第二个版本的 sleep_for() 中没有触发警告的原因是因为在 stop_callback 中,你在调用 cv.notify_one(); 之前没有尝试锁定互斥体。 std::condition_variable_any 正是这样做的,请参阅 condition_variable:404 和 condition_variable:298: // line 404: std::stop_callback __cb(__stoken, [this] { notify_all(); }); // lines 295-300: void notify_all() noexcept { lock_guard<mutex> __lock(*_M_mutex); _M_cond.notify_all(); } 我相信这对应于您警告中的堆栈跟踪: #4 std::_V2::condition_variable_any::notify_all() /usr/include/c++/11/condition_variable:299 (MyAppTest+0x857f6) #5 operator() /usr/include/c++/11/condition_variable:404 (MyAppTest+0x2d9556) 编辑: 基于 为什么 C++20 std::condition_variable 不支持 std::stop_token? 如果 sleep_for() 中的锁丢失,您的第二个版本 stop_callback 可能存在竞争条件。 让我们看看, std::condition_variable::wait_for (2) 表示它相当于 wait_until() ,而 std::condition_variable::wait_until (2) 表示它相当于: while (!pred()) { if (wait_until(lock, timeout_time) == std::cv_status::timeout) { return pred(); } } 一些可能的情况: 看门狗线程:在 wait_until() 内部,它会发生虚假唤醒,调用您的谓词,该谓词返回 false。在它有机会再次调用 wait_until() 之前... 主线程:停止看门狗线程,执行stop_callback,调用notify_all()... watchdog 线程:错过通知,因为它还没有调用 wait_until()。它现在调用它并等待直到超时(或另一个虚假唤醒)。 结果,线程在应该停止的时候却没有停止。

回答 1 投票 0

为什么gcc-7.5.0生成不同的重定位条目

我正在研究elf重定位,注意到在我们学校的容器中,编译了如下c文件: int sum(int *a, int n) { 返回a[0]+a[1]; } int 数组[2] = {1, 2}; int main() { int val = ...

回答 1 投票 0

有没有办法强制c++编译器不优化静态库中的特定静态对象?

(如果找不到通用解决方案,只需要适用于gcc 5.4) 我有一个通用工厂,用于根据某个键(如表示类名的字符串)构造对象。事实...

回答 2 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.