I have a diff of two files. They differ very slightly in practice, but in implementation they vary greatly. One uses preprocessor constants to set bits, and the other does not. For example:
< output(0x1020 + 0x80, 0x8FFF1FF4)
> output(BASE + OFFSET, COMMAND | COMMAND_DO_SOMETHING | COMMAND_DO_SOMETHING_SUBCOMMAND1) //this works out to output(0x1100, 0x8FFFF1FF8)
Doing the reduction by hand is time consuming (there are a lot of these). Ideally I'd like to see the first one in macros, but the second works as well (I can re-diff to see what actually differs then go backwards by hand).
Is there a way to throw a header file at an arbitrary file (of course it doesn't follow C syntax because it's a diff) and see what pops out?
If I understand what you are asking, you want to run a file through the C preprocessor and have any macros defined in another header file expanded in it? You can do that with gcc by running
$ gcc -imacros header.h -E diff-file
which will read header.h to get any macros defined in it, then read diff-file
expanding any macros found and echo the result to stdout. You may be able to do something similar with other compilers -- perhaps create a file that has
#include "header.h"
#include "diff-file"
and then run cc -E file
. You'll get a copy of the other stuff in header.h in the output, but you can ignore that.