Article View: comp.unix.programmer
Article #3604Re: gethostname() with -pedantic -ansi flags
From: Kaz Kylheku
Date: Wed, 05 Apr 2000 00:00
Date: Wed, 05 Apr 2000 00:00
25 lines
2030 bytes
2030 bytes
On Tue, 04 Apr 2000 18:01:47 -0600, Jeff Shipman <shippy@cs.nmt.edu> wrote: >Sorry if this is not the correct newsgroup to post to. I >wasn't sure which one would be right. My problem is that >I'm compiling my program with the -pedantic and -ansi >flags and I get the following warning: > >cb.c:348: warning: implicit declaration of function `gethostname' > >I am including unistd.h and it compiles just fine if I >leave out those two flags. Is it because gethostname() >is not ANSI C? Not quite. It's true that this function is not ANSI C, but then again, neither is the <unistd.h> header. What is happening is that you are getting only the minimal set of identifiers out of this POSIX header; you need to add a feature selection macro something like _XOPEN_SOURCE to enable addtional things that are not in POSIX. In other words, in additon to supressing extensions in ANSI C headers and ensuring that the compiler accepts all ANSI C programs, the -ansi option also suppresses extensions in other headers, allowing you to use feature selection macros to enable specific interface standards. -- #exclude <windows.h>
Technical Details
Message-ID:
<slrn8el12q.n9t.kaz@ashi.FootPrints.net>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<38EA826B.74E7DECA@cs.nmt.edu>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,98a1efd33b1208fc X-Google-Attributes: gid11318c,public X-Google-Thread: fc89c,98a1efd33b1208fc X-Google-Attributes: gidfc89c,public X-Google-Thread: 1014db,98a1efd33b1208fc X-Google-Attributes: gid1014db,public From: kaz@ashi.footprints.net (Kaz Kylheku) Subject: Re: gethostname() with -pedantic -ansi flags Date: 2000/04/05 Message-ID: <slrn8el12q.n9t.kaz@ashi.FootPrints.net> X-Deja-AN: 606819338 References: <38EA826B.74E7DECA@cs.nmt.edu> X-Complaints-To: abuse@direct.ca X-Trace: brie.direct.ca 954893232 204.239.179.1 (Tue, 04 Apr 2000 17:07:12 PDT) Organization: Psycho-Neurotic Institute for The Very, Very Nervous User-Agent: slrn/0.9.5.7 (UNIX) Reply-To: kaz@ashi.footprints.net NNTP-Posting-Date: Tue, 04 Apr 2000 17:07:12 PDT Newsgroups: comp.unix.programmer,comp.lang.c,gnu.gcc.help