How can I generate unique values in the C preprocessor?

后端 未结 6 1175
南笙
南笙 2020-11-27 04:54

I\'m writing a bunch of related preprocessor macros, one of which generates labels which the other one jumps to. I use them in this fashion:

MAKE_FUNNY_JUMPI         


        
6条回答
  •  青春惊慌失措
    2020-11-27 05:33

    It doesn't seem possible with a standard preprocessor, although you could fake it out by putting parameters within MAKE_LABEL or MAKE_FUNNY_JUMPING_LOOP, and use token pasting to create the label.

    There's nothing preventing you from making your own preprocessing script that does the automatic increment for you. However, it won't be a standard C/C++ file in that case.

    A list of commands available: http://www.cppreference.com/wiki/preprocessor/start

提交回复
热议问题