Hi,
I'm interested in (re)writing a bunch of drivers for a project in
assembly, which will be called from C routines. The Compiler and
Assembler are GNU gcc and as.
I plan to run the Assembly language files through the C pre-processor
before actual assembly, so that a single header file can be shared
between the assembly driver routines and the C interface to the routine.
However, I'm having a problem trying to find a good and clean approach
for dealing with enums. Is there a way to define enums such that they
can be referenced correctly in both Assembly and C, without duplicating
it manually like in the following code fragment.
1 | #ifndef __ASSEMBLY___
|
2 | typedef enum { ENUM_A, ENUM_B, ... } enumvalues;
|
3 | #else
|
4 |
|
5 | #define ENUM_A 0
|
6 | #define ENUM_B 1
|
7 | ...
|
8 |
|
9 | #endif
|
TIA