compiler-flags

How to build a program with 2 different values of a variable in CMake

心不动则不痛 提交于 2019-12-03 12:47:29
问题 I've recently ported my Qt project from qmake to CMake . My main program contains a value which depends on a #define directive. I want to specify that define directive externally via CMake and build 3 differently named versions of the same executable. How should I do it? I've seen set_target_properties but this only works for libraries and not for executables. For example I want that the following program, int main() { cout << BUILDTYPE << endl; } it's compiled in 3 different flavors (3

What's the difference between the -symbolic and -shared GCC flags?

泄露秘密 提交于 2019-12-03 07:39:59
问题 From the documentation's description, they seem to do the same thing except that "not all systems" support shared and "only some systems" support symbolic (it's unclear if these are the same set of systems): -shared Produce a shared object which can then be linked with other objects to form an executable. Not all systems support this option. For predictable results, you must also specify the same set of options that were used to generate code (-fpic, -fPIC, or model suboptions) when you

How to force xcode to use ARC on a specific file?

余生颓废 提交于 2019-12-03 05:05:54
My project contains XMPPFramework which contains a file that has to be used with ARC. But my project is Non ARC and cannot be converted due to certain other libraries linked to it. How do I force the compiler to use ARC only on a certain class ? justin It is the inverse problem of this question . The difference is that you would use -fobjc-arc instead of -fno-objc-arc . 来源: https://stackoverflow.com/questions/13392521/how-to-force-xcode-to-use-arc-on-a-specific-file

Does set_target_properties in CMake override CMAKE_CXX_FLAGS?

╄→гoц情女王★ 提交于 2019-12-03 02:09:43
问题 At the beginning of my CMake project, I'm setting general compilation flags in the variable CMAKE_CXX_FLAGS, like set(CMAKE_CXX_FLAGS "-W -Wall ${CMAKE_CXX_FLAGS}") Later on, I need to append additional configuration-specific compilation flags (stored in BUILD_FLAGS). Can I use the following command for this: set_target_properties(${TARGET} PROPERTIES COMPILE_FLAGS ${BUILD_FLAGS}) or do I have to add the CMAKE_CXX_FLAGS manually: set_target_properties(${TARGET} PROPERTIES COMPILE_FLAGS "$

What's the differrence among cflgs sse options of -msse, -msse2, -mssse3, -msse4 rtc..? and how to determine?

心不动则不痛 提交于 2019-12-03 01:40:08
For the GCC CFLAGS options: -msse , -msse2 , -mssse3 , -msse4 , -msse4.1 , -msse4.2 . Are they exclusive in their use or can the be used together? My understanding is that the choosing which to set depends on whether the target arch, which the program will run on, supports it or not, is this correct? If so, how could I know what sse my target arch supports? In Linux, I cat /proc/cpuinfo, but what if mac or Windows? Thanks! The -m switched can be used in parallel, furthermore some of them are implied by the architecture or other switches. For instance, if you build code for x86_64, -msse -msse2

Undefined behavior from pointer math on a C++ array

会有一股神秘感。 提交于 2019-12-03 01:26:13
Why the output of this program is 4 ? #include <iostream> int main() { short A[] = {1, 2, 3, 4, 5, 6}; std::cout << *(short*)((char*)A + 7) << std::endl; return 0; } From my understanding, on x86 little endian system, where char has 1 byte, and short 2 bytes, the output should be 0x0500 , because the data in array A is as fallow in hex: 01 00 02 00 03 00 04 00 05 00 06 00 We move from the beginning 7 bytes forward, and then read 2 bytes. What I'm missing? You are violating strict aliasing rules here. You can't just read half-way into an object and pretend it's an object all on its own. You can

What's the difference between the -symbolic and -shared GCC flags?

我们两清 提交于 2019-12-02 21:07:18
From the documentation's description, they seem to do the same thing except that "not all systems" support shared and "only some systems" support symbolic (it's unclear if these are the same set of systems): -shared Produce a shared object which can then be linked with other objects to form an executable. Not all systems support this option. For predictable results, you must also specify the same set of options that were used to generate code (-fpic, -fPIC, or model suboptions) when you specify this option.[1] -symbolic Bind references to global symbols when building a shared object. Warn

Is there any way to override the -fvisibility=hidden at link time?

时光怂恿深爱的人放手 提交于 2019-12-02 18:05:00
问题 We are using an third party static library, let say A.a for android development. We link it as shared library and it works fine in the one App, but when use B.so to build another C.so , some symbols in A.a cannot find. We have already use -Wl,--export-dynamic and -Wl,--whole-archive to build B.so . We have using nm to check those symbols, it exist but list as “t” instead of “T” ,which means it is local symbols instead of external. Seams the A.a are build with -fvisibility=hidden after som

Does set_target_properties in CMake override CMAKE_CXX_FLAGS?

天涯浪子 提交于 2019-12-02 17:14:59
At the beginning of my CMake project, I'm setting general compilation flags in the variable CMAKE_CXX_FLAGS, like set(CMAKE_CXX_FLAGS "-W -Wall ${CMAKE_CXX_FLAGS}") Later on, I need to append additional configuration-specific compilation flags (stored in BUILD_FLAGS). Can I use the following command for this: set_target_properties(${TARGET} PROPERTIES COMPILE_FLAGS ${BUILD_FLAGS}) or do I have to add the CMAKE_CXX_FLAGS manually: set_target_properties(${TARGET} PROPERTIES COMPILE_FLAGS "${CMAKE_CXX_FLAGS} ${BUILD_FLAGS}") to prevent CMAKE_CXX_FLAGS being overriden by BUILD_FLAGS? Use the first

Visual Studio (2015) fpermissive equivalent flag

风流意气都作罢 提交于 2019-12-02 14:41:04
问题 In VS2015 is there an equivalent flag of GCC -fpermissive? That's for a cpp application Thanks S. 回答1: VC++ compiler permissive by default, but you can disable it using compiler flag /permissive- starting with VS2015 Update 3 回答2: The theoretical equivalent is /Ze . However, this allows Microsoft-specific extensions, whereas -fpermissive allows GCC-specific extensions. If you want your code to be portable, write portable code. It's that simple. 来源: https://stackoverflow.com/questions/36119137