RFC: target-defs.h inclusion backwards?
DJ Delorie
dj@redhat.com
Mon Jul 21 22:48:00 GMT 2003
Currently we do this:
---------- target-defs.h
#define TARGET_A default_a
#define TARGET_B default_b
#define TARGET_C default_c
---------- tm.c
#include "target-defs.h"
#undef TARGET_A
#define TARGET_A my_a
#undef TARGET_B
#define TARGET_B my_b
#undef TARGET_C
#define TARGET_C my_c
struct gcc_target targetm = TARGET_INITIALIZER;
----------
Wouldn't it be better if we did this instead?
---------- tm.c
#define TARGET_A my_a
#define TARGET_B my_b
#define TARGET_C my_c
#include "target-defs.h"
---------- target-defs.h
#ifndef TARGET_A
#define TARGET_A default_a
#endif
#ifndef TARGET_B
#define TARGET_B default_b
#endif
#ifndef TARGET_C
#define TARGET_C default_c
#endif
struct gcc_target targetm = TARGET_INITIALIZER;
----------
There's lots of targets but only one target-defs.h; we should put the
syntax onus on target-defs.h and make the tm.c files as simple and
clean as possible.
It also allows target-defs.h to handle cases of paired macros, like an
array and its size (or more complex examples) a little more flexibly,
plus detect missing mandatory macros better (i.e. give a useful #error
rather than emit a syntax error in a huge struct initializer).
More information about the Gcc
mailing list