simplecpp icon indicating copy to clipboard operation
simplecpp copied to clipboard

Prevent change of spacing

Open agners opened this issue 7 years ago • 5 comments

When trying to reuse the simplecpp for device tree it turns out that simplecpp changes spacing such that the output can't be read by the device tree compiler. simplepcc inserts a space between the ampersand and the label, such that they can not be read by dtc, e.g. & gpio).

It would be nice to have an option which preserves spaces as much as possible.

agners avatar Sep 28 '18 12:09 agners

how do you use simplecpp? on the command line like this:

simplecpp 1.c

?

I would personally prefer that you use the token list output instead but that might be more complex for you. you then have to write a c++ program (you can just tweak simplecpp/main.cpp) that uses simplecpp.

danmar avatar Sep 29 '18 06:09 danmar

I think that we want to have 2 different behaviors. For debugging I want to see what tokens are created so I want to have the extra space. Users do not want to have extra spaces. So I need to add some debug flag that I can use.

If you want to try to fix this the feel free to look at it. I believe that you can just tweak simplecpp::TokenList::stringify in simplecpp.cpp.

danmar avatar Sep 29 '18 06:09 danmar

I try to use it as drop in replacement for GCC's preprocessor to preprocess Linux kernel device trees. The GCC command looks like this:

cpp -nostdinc -x assembler-with-cpp -I../linux/include/ -o output.dts.tmp input.dts

The simplecpp command looks like this:

simplecpp -D__DTS__ -I../linux/include/ input.dts > output.dts.tmp

agners avatar Oct 01 '18 13:10 agners

Why not use gcc? The text output is for debugging purposes. It is tricky to get the spacing exactly as gcc and I rather not worry about if the debug output is exactly like gcc or not.

danmar avatar Apr 27 '19 15:04 danmar

To me this is currently a low prio issue.

danmar avatar Apr 27 '19 15:04 danmar