c preprocessor - How to process C++ file to remove ifdef'd out code -


i have inherited piece of c++ code has many #ifdef branches adjust behaviour depending on platform (#ifdef __win32, #ifdef __apple__, etc.). code unreadable in current form because these preprocessor directives nested, occur in middle of functions , in middle of multi-line statements.

i'm looking way of somehow specifying preprocessor tags , getting out copy of code if code had been pre-processed flags. i'd headers left untouched, though. example:

#include <iostream>  #ifdef __apple__ std::cout << "this apple!" << std::endl; #elif __win32 std::cout << "this windows" << std::endl; #endif 

would turn into:

#include <iostream>  std::cout << "this apple!" << std::endl; 

after being processed by: tool_i_want example.cpp __apple__.

i've hacked quick script similar, i'd know of better tested , more thorough tools. running linux distribution.

i have decided against running c-preprocessor because if i'm not mistaken expand header files, make more unreadable.

use unifdef. designed purpose.


Comments

Popular posts from this blog

How to get the arclen between two curve points in Maya? -

C++ Linked List -

git svn - Unignore directories in git-svn (adding directories to a sparse checkout) -