public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Deprecate not defining NO_IMPLICIT_EXTERN_C
@ 2018-03-21 12:32 Nathan Sidwell
  2018-03-21 14:18 ` Richard Earnshaw (lists)
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Nathan Sidwell @ 2018-03-21 12:32 UTC (permalink / raw)
  To: GCC Patches, Jason Merrill
  Cc: Richard Earnshaw, rth, gnu, Nick Clifton, chertykov, jzhang918,
	Bernd Schmidt, hp, james.bowman, Jeff Law, Jan Hubicka,
	Jim Wilson, sebastien, eager, clm, green, jasonwucj, cltang, tom,
	ni1d, kito.cheng, dj, David Edelsohn, hepenner, Alexandre Oliva,
	davem, walt, matt, ebotcazou, augustine.sterling

Port maintainers CC'd, apologies if I've missed you.

NO_IMPLICIT_EXTERN_C is a target machine define that turns off wrapping 
system header files in 'extern "C" { ... }'.  It is the remaining 
non-deprecated ARM-era compatibility behaviour.  Can we deprecated it?

Unfortunately it's a negative-sense define, that now at least most ports 
define.  Do all ports define it?  It's hard to determine that, because 
many ports get it set via config/gnu-user.h or similar common file.

It also has the following undocumented features (when not set):
1) in a system header in an extern "C" region, a prototype of the form 
'T func ()' means unspecified parms.   We treat it as (...), but that's 
not valid C and probably will do the wrong thing with today's more 
complex ABIs.

2) Again, in a system header for extern "C" fns, enables matching 
between function prototypes via self-promoting parameter types.  I.e. 
'extern "C" T foo (char)' and 'extern "C" T foo (int)' are the same fn.

The path by which the extern "C" wrapping happens is tortuous though 
c-family/c-lex.c via a global variable and the parser setting flags on 
each token.  Ugh!

I think the way of going about that would be to require it to be defined 
to either 0 or 1, and test that, rather than its definedness.  Then any 
ports that require the old behaviour will need to set it to zero, 
explicitly indicating the requirement.  Something like:

// in default.h
#if !defined (NO_IMPLICIT_EXTERN_C) \
   || (0 - NO_IMPLICIT_EXTERN_C - 1) > 0 /* Detect blank */
#error NO_IMPLICIT_EXTERN_C must be defined to 0 or 1, see XXX
#endif

modify the existing #defines to provide a value.

modify the uses from
   #ifndef NO_IMPLICIT_EXTERN_C
into
   #if !NO_IMPLICIT_EXTERN_C

(That's just as vulnerable to misspellings of the name as the ifndef 
case, and we're converting existing code, so probably quite safe.)

My suspicion is that pdp11 and/or vax may care?

Comments/Objections?

nathan
-- 
Nathan Sidwell

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

end of thread, other threads:[~2018-03-22 12:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-21 12:32 Deprecate not defining NO_IMPLICIT_EXTERN_C Nathan Sidwell
2018-03-21 14:18 ` Richard Earnshaw (lists)
2018-03-21 14:38 ` David Edelsohn
2018-03-21 15:42   ` Nathan Sidwell
2018-03-21 21:33 ` Joseph Myers
2018-03-22 12:16   ` Nathan Sidwell

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).