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 e.g. Variadic Macros. So my preprocessor fails.
So, is there a way to use the Cl.exe to preprocess my source code e.g. 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 e.g. variadic template etc.