This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: extern const and all that


Gabriel Dos Reis <gdr@integrable-solutions.net> writes:

[...]

| /* In order to avoid dragging in all the headers that are needed to
|    declare things that gensupport.h uses, we duplicate the declaration
|    of struct c_test here.  (In particular we do not want to have to
|    include tm.h nor rtl.h in this file.)  */
|  
| Given that constraint, it appears to me that putting "extern" in the
| definition is the minimal, viable solution.  

An alternative is just this:

Index: dummy-conditions.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/dummy-conditions.c,v
retrieving revision 1.4
diff -p -r1.4 dummy-conditions.c
*** dummy-conditions.c  12 Aug 2004 07:48:51 -0000      1.4
--- dummy-conditions.c  10 Jun 2005 04:52:27 -0000
***************
*** 27,33 ****
  /* In order to avoid dragging in all the headers that are needed to
     declare things that gensupport.h uses, we duplicate the declaration
     of struct c_test here.  (In particular we do not want to have to
!    include tm.h nor rtl.h in this file.)  */
  struct c_test
  {
    const char *expr;
--- 27,38 ----
  /* In order to avoid dragging in all the headers that are needed to
     declare things that gensupport.h uses, we duplicate the declaration
     of struct c_test here.  (In particular we do not want to have to
!    include tm.h nor rtl.h in this file.)  For the same reasons, we
!    repeat the "extern" declarations for the const variable here.  We
!    could have used the "extern" specifier directly in their definitions,
!    but then gcc would produce a warning which will cause a failure.  The
!    "extern" specifier is necessary for preserving the same meaning in
!    C++ (which assumes internal linkage by default for const objects.)  */
  struct c_test
  {
    const char *expr;
*************** struct c_test
*** 35,42 ****
--- 40,51 ----
  };
  
  /* Empty conditions table to prevent link errors.  */
+ extern const struct c_test insn_conditions[];
+ extern const size_t n_insn_conditions;
+ 
  const struct c_test insn_conditions[1] = { { 0, 0 } };
  const size_t n_insn_conditions = 0;
  
  /* Disable insn elision, since it is currently impossible.  */
+ extern const int insn_elision_unavailable;
  const int insn_elision_unavailable = 1;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]