Received: from SOUTH-STATION-ANNEX.MIT.EDU by po7.MIT.EDU (5.61/4.7) id AA18936; Sat, 30 Sep 95 02:28:07 EDT
Received: from SUN-LAMP.PC.CS.CMU.EDU by MIT.EDU with SMTP
	id AA26305; Sat, 30 Sep 95 02:27:40 EDT
Received: from pain.lcs.mit.edu (pain.lcs.mit.edu [128.52.46.239]) by sun-lamp.pc.cs.cmu.edu (8.6.11/8.6.10) with ESMTP id CAA04373; Sat, 30 Sep 1995 02:28:04 -0400
Received: (from daemon@localhost) by pain.lcs.mit.edu (8.6.9/8.6.9) id BAA28438; Sat, 30 Sep 1995 01:27:52 -0400
Received: from BALVENIE.PDL.CS.CMU.EDU by pain.lcs.mit.edu (8.6.9/8.6.9) with SMTP id BAA28250; Sat, 30 Sep 1995 01:18:29 -0400
Received: from LOCALHOST by BALVENIE.PDL.CS.CMU.EDU id aa05714;
          30 Sep 95 1:18 EDT
To: John Birrell <cimaxp1!jb@werple.net.au>
Cc: port-alpha@NetBSD.ORG, jb@cimlogic.com.au, tech-userlevel@NetBSD.ORG
X-Copyright: Copyright 1995, Christopher G. Demetriou.  All rights reserved.
X-Notice: Duplication and redistribution prohibited without consent of
	  the author.
Subject: Re: gcc -nostdinc && -Wall 
In-Reply-To: Your message of "Sat, 30 Sep 1995 09:56:14 +1000."
             <199509292353.JAA06292@werple.net.au> 
Date: Sat, 30 Sep 1995 01:16:56 -0400
Message-Id: <5681.812438216@BALVENIE.PDL.CS.CMU.EDU>
From: Chris G Demetriou <Chris_G_Demetriou@BALVENIE.PDL.CS.CMU.EDU>
Sender: owner-tech-userlevel@NetBSD.ORG
Precedence: list
X-Loop: tech-userlevel@NetBSD.ORG

[ note that i've expanded the cc list some... ]

>When I compile a function (under NetBSD/Alpha) like ....
> 
>----------------------------------------------
>#include <stdio.h>
>int main()
>{
>    return(0);
>}
>----------------------------------------------
> 
>with the command...
> 
>cc -c -Wall testx.c
> 
>I get a clean compile (no warnings).
> 
>When I use the command...
> 
>cc -c -Wall -nostdinc -I/usr/include testx.c
> 
>I get the following warning...
> 
>/usr/include/stdio.h:335: warning: `__sputc' defined but not used
>
>[ ... ]
>
>When I do the same thing under NetBSD/i386 I don't get the warning and I don't
>get __sputc in the object module. This seems like the _correct_ behavio[u]r.

I don't know why you're getting the .text entry, but:

> Is this a problem with gcc? Chris, does your new compiler do the same thing?

Yes, the new compiler does the same thing, and, looking at the
compiler sources, it's a "feature."  (grep -i around the gcc sources
for "in_system_header".)


if you run cc -E rather than cc -c on the files, and compare the cpp
output, you'll note that the line directives have a trailing:
	" 3"
added if the files come from the builtin include path.

i.e. if you compile normally, a line directive might look like:

# 1 "/usr/include/stdio.h" 1 3

whereas if you compile with -nostdinc -I/usr/include, then they'll
look like:

# 1 "/usr/include/stdio.h" 1


that trailing "3" means "this was a system include file."  gcc then
uses this to suppress certain warnings (e.g. some 'long long'
warnings, obviously that "unused function" declaration, etc.), and
obviously does a few things differently based on that flag.

Thinking about it, it's not clear whether, on a system such as NetBSD:
	(1) recognition of that flag should be suppressed (so that
	    files compiled with -Wall are _really_ completely
	    checked), or
	(2) by default, the system should be compiled with
		-nostdinc -I/usr/include


thoughts?



chris
