This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RFC: target-defs.h inclusion backwards?
- From: DJ Delorie <dj at redhat dot com>
- To: gcc at gcc dot gnu dot org
- Date: Mon, 21 Jul 2003 17:53:46 -0400
- Subject: RFC: target-defs.h inclusion backwards?
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).