How to preprocess the code base using the clang (or gcc) preprocessor, limiting its text processing to use only #define entries from a single header file?
This is useful in general: imagine you want to see the direct result of some of the macros that you are currently working on ... without any mess that arises from the mountain of inclusions inherent in C.
Imagine a case where there are macros that provide a callback compatible or updated based on the availability of functions.
#if __has_feature(XYZ) # define JX_FOO(_o) new_foo(_o) # define JX_BAR(_o) // nop ... #else # define JX_FOO(_o) old_foo(_o) # define JX_BAR(_o) old_bar(_o) ... #endif
A specific example is an Objective-C code set that has been ported as ARC-compatible (automatic reference counting) from manual memory management (not ARC) using a macro set ( https://github.com/JanX2/google-diff-match- patch-Objective-C / blob / master / JXArcCompatibilityMacros.h ) to subsequently compile both paths.
At some point, you want to give up support without ARC to improve readability and maintainability.
Edit: the base for receiving preprocessor output is described here: C, Objective-C preprocessor output
Edit 2: If someone has information on how the source-to-source conversion options are implemented in Xcode (Edit> Refactor> Convert To ...), this may help.
source share