'Reverse' a collection of C preprocessor macros easily

后端 未结 2 1059
难免孤独
难免孤独 2020-12-04 00:49

I have a lot of preprocessor macro definitions, like this:

#define FOO 1
#define BAR 2
#define BAZ 3

In the real application, each

2条回答
  •  难免孤独
    2020-12-04 01:30

    In a similar case I've resorted to defining a text file format that defines the instructions, and writing a program to read this file and write out the C source of the actual instruction definitions and the C source of functions like your instruction_by_id(). This way you only need to maintain the text file.

提交回复
热议问题