How to apply a C preprocessor only to certain (#if/#endif) directives?

后端 未结 4 1984
攒了一身酷
攒了一身酷 2021-01-16 04:27

I was wondering if it is possible, and if yes how, can I run a C preprocessor, like cpp, on a C++ source file and only process the conditional directives #

4条回答
  •  青春惊慌失措
    2021-01-16 05:00

    Oh, this is the same task as I had in the past. I've tried cpp unifdef and coan tools - all of them stumbled upon special C# preprocessor things like #region. In the end I've decided to make my own one: https://github.com/gaDZella/undefine.

    The tool has a pretty simple set of options compared to the mentioned cpp tools but it is fully compatible with C# preprocessor syntax.

提交回复
热议问题