public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* C option processing, header inclusion ordering dependencies
@ 2012-07-17 22:18 Mike Stump
  2012-07-17 22:57 ` Joseph S. Myers
  0 siblings, 1 reply; 2+ messages in thread
From: Mike Stump @ 2012-07-17 22:18 UTC (permalink / raw)
  To: gcc@gcc.gnu.org List

In doing up the mods for the constant wide int code, we found a nasty including ordering problem that seems only tangentially related to our code.  In options.h this is generated:

/* Anything that includes tm.h, does not necessarily need this.  */
#if !defined(GCC_TM_H)
#include "input.h" /* for location_t */
bool                                                                  
common_handle_option_auto (struct gcc_options *opts,                  
                           struct gcc_options *opts_set,              
                           const struct cl_decoded_option *decoded,   
                           unsigned int lang_mask, int kind,          
                           location_t loc,                            
                           const struct cl_option_handlers *handlers, 
                           diagnostic_context *dc);

and produces a nasty dependency on include ordering that's annoying to track down as it fails only in the C++ bootstrap.  If one includes tm.h first, then c-opts.c doesn't compile with C++ but does with C.  If one adds a #include "options.h" before the #include "tm.h", then things are fine.  :-(  Changing the contents of the include based upon something as trivial as the include ordering is, nasty.  So, that said, in a new file we'll be submitting shortly to handle wide int constants (wide-int.h), we have a #include "tm.h", and we don't use options.h, but without a #include of options.h first, c-opts.c won't compile.  Needless to say, tree.h will include the wide-int.h header file...  I'm sure this was engineered to work in come fashion, but, that escapes me, what is the correct dance ensure the prototypes in options.h are present?  Include options.h at the top of c-opts.c, to ensure it comes before tree.h (which is the file that includes the wide-int.h header, include options.h in wide-int.h?

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: C option processing, header inclusion ordering dependencies
  2012-07-17 22:18 C option processing, header inclusion ordering dependencies Mike Stump
@ 2012-07-17 22:57 ` Joseph S. Myers
  0 siblings, 0 replies; 2+ messages in thread
From: Joseph S. Myers @ 2012-07-17 22:57 UTC (permalink / raw)
  To: Mike Stump; +Cc: gcc@gcc.gnu.org List

On Tue, 17 Jul 2012, Mike Stump wrote:

> In doing up the mods for the constant wide int code, we found a nasty 
> including ordering problem that seems only tangentially related to our 
> code.  In options.h this is generated:

Maybe such prototypes in options.h, that don't actually depend on anything 
in the .opt files, would better go in opts.h (unconditionally)?  I think 
that should avoid the ordering issue you describe.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-07-17 22:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-17 22:18 C option processing, header inclusion ordering dependencies Mike Stump
2012-07-17 22:57 ` Joseph S. Myers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).