I have some constants or it determines that I use both the C program and the Python program, however I defined them separately in both files. It would be nice to have one .h file that I could use for C and Python programs to avoid having to make changes in two places.
u16 get_opt(int arg) {
u16 mode;
if(arg == 1) {
mode = 0xabc1;
} else if (arg == 2) {
mode = 0xf104;
} else if(arg == 3) {
mode = 0xff16;
}
return mode;
}
In python, I also have
MAPPING = {
1: 0xabc1,
2: 0xf104,
3: 0xff16
}
def get_opt(arg) {
return MAPPING[arg]
}
I have many constant values ββto determine which access I need from both the C program and the Python program, so I was wondering if there is a good way to implement it.
source
share