- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我使用 GoogleTest 测试我的 C++ 项目,发现 Ubuntu 包中不再分发预编译库后,我在项目网站上找到了以下内容:
If you compile Google Test and your test code using different compiler flags, they may see different definitions of the same class/function/variable (e.g. due to the use of #if in Google Test). Therefore, for your sanity, we recommend to avoid installing pre-compiled Google Test libraries. Instead, each project should compile Google Test itself such that it can be sure that the same flags are used for both Google Test and the tests.
我从中得出的结论是,将 GoogleTest 与正在测试的项目分开编译是个坏主意。我不明白的是这是否只是 GoogleTest 的事情,或者这是否是链接库的一般事情。
问题
是否存在链接到预编译的第三方库、编译器标志或其他不安全的情况,如果没有,GoogleTest 有什么特别之处?
最佳答案
有一些编译器标志,特别是那些与对齐一起使用的标志,可能会导致问题。
-malign-double
-mno-align-double
Control whether GCC aligns double, long double, and long long variables on a two-word boundary or a one-word boundary. Aligning double variables on a two-word boundary produces code that runs somewhat faster on a Pentium at the expense of more memory.
On x86-64, -malign-double is enabled by default.
Warning: if you use the -malign-double switch, structures containing the above types are aligned differently than the published application binary interface specifications for the 386 and are not binary compatible with structures in code compiled without that switch.
例如,在 32 位系统上使用该标志将使 double 和 long long 为 64 位对齐。如果您编译一个没有标志的库,然后尝试在使用该标志的同时使用该库,则包含上述类型的结构可能具有不同的对齐方式,并且可能无法互操作。
其他(更简单的)情况也可以确保使用同一组#defines 以确保使用相同的函数/结构/类定义(以及其他此类 ODR 违规)。例如,在 gcc 中使用 '--std=c++11',它启用标准库类的 C++ 11 版本,在某些情况下与以前的版本不同。
关于c++ - 链接到使用不同编译器标志构建的静态库是否安全,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12867161/
我正在开发一个 voip 调用应用程序。我需要做的是在接到来电时将 Activity 带到前台。我在应用程序中使用 Twilio,并在收到推送消息时开始调用。 问题是我试图在接到任何电话时显示 Act
我是一名优秀的程序员,十分优秀!