C , C++, C#

Cmake에서 WIN 매크로

vhxpffltm 2022. 12. 15. 22:38
반응형

개발하거나 유지보수할때 보면..

 

WIN32 관련 매크로가 정말 많다.

 

보통 _WIN32는 32bit 윈도우, _WIN64 는 64bit 윈도우라 생각할수 있는데...

 

그것이 아니었다

 

https://stackoverflow.com/questions/6679396/should-i-define-both-win32-and-win64-in-64bit-build

 

Should I define both _WIN32 and _WIN64 in 64bit build?

When we add a 64bit configuration from a 32bit project that has already existed, Visual Studio copies the 32bit configurations by default. VS even copies _WIN32 All my 64bit projects define also _W...

stackoverflow.com

 

위 글처럼 _WIN32는 윈도우 바이너리 그 중에서 _WIN64는 64bit 윈도우 바이너리를 나타낸다.

 

아래 표를 참고해서 아키텍처와 관련된 바이너리를 잘 기억해두자.

 

출처: https://flowerexcel.tistory.com/9

 

그러면서...

 

CMake로 프로젝트를 제너레이터 하는데...

 

WIIN32 라는 매크로가 모든 응용 프로그램 프로젝트에 전처리기로 정의되어 있는게 있었다...

암만 봐도.. 뭔가 좀 이해할 수 없다..

 

CMakeLists.txt에서 WIN32 라는 키워드가 있는데..

이것을 사용하면 무조건 전처리기 정의에 WIN32가 정의된다.

이를 원치않는다면.. compile_option을 통해 따로 설정하도록 해야한다.

 

https://stackoverflow.com/questions/9742003/platform-detection-in-cmake

 

Platform detection in CMake

I've added some functionality from boost::asio, which has precipitated some compiler "warnings": Please define _WIN32_WINNT or _WIN32_WINDOWS appropriately. That problem was dealt with here. I'...

stackoverflow.com

 

반응형