简体   繁体   中英

How can I use the Visual Studio C/C++ Compiler (cl.exe) to pre-process my objective-C code?

I have some old Objective-C code which I am trying to compile using my custom-build framework. This build framework preprocesses the source files, then compiles them to C-Source code and then uses Cl.exe to do the rest of compiling.

However, when I try to do the same with VS2015, it fails in my preprocessing phase. As from VS2015 VCRuntime.h is included in all files indirectly and uses newer C++ features eg Variadic Macros. So my preprocessor fails.

So, is there a way to use the Cl.exe to preprocess my source code eg unwinding #includes, evaluating #defines etc without being concerned about the actual code? I tried cl.exe /Tp but didn't work. However this option does understand #imports

I finally figured it out.

The cl.exe /Tp /E /I command could work to some extend preprocessing both objective-c (.m) and c (.c) source files. However it fails to parse few of the COM related code.

Then I found an open-source C-Pre-Processor that can successfully preprocess .c, .cpp and .m files . The benefit of this tool is, it supports C++ 11 features as well eg variadic template etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM