use mcpp to preprocess sources before CppReverse #74
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This branch is NOT complete as it never actually /uses/ the included code, but it includes all the code to actually do the preprocessing. All that is necessary is a call to j_preprocess in preprocess.h
The arguments are mostly self-explanatory.
fin is the input file
fout is passed by reference. The location of the output file will be placed there.
include_args is the list of arguments to the preprocessor (such as "-I/usr/local/include", etc)
working_dir is the working directory for the preprocessor
errstream is a pointer to a string where the errors the preprocessor outputs will be stored
output_includes is a boolean option. If false, the preprocessor will not output text from included files (but will process it for macros).
The return value is an error code (0 indicates no error).
What is needed is the gui code to feed these options to the function j_preprocess, and simply use the preprocessed file as input to the lexer instead of the original.
mcpp will continue outputting through recoverable errors (such as #error directives or missing #includes), but we could include an option to discard the output if any errors occur.
mcpp is also highly portable (although I fiddled with the configuration a bit, so it is possible that it will need some patches to maintain its portability in this stripped form).
I have tested this on 64 bit debian/linux.