Path: csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Error messages Date: Fri, 17 Jul 2015 07:54:37 -0700 Organization: None to speak of Lines: 45 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="945944de09706c9b4e29b53c9d2efdc2"; logging-data="6162"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ttZtcjDG0PYXBM8PN0Jv1" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:AUgxLFqK2z3/7duXmLswCgl8Fg8= sha1:JmSeefTr0AylS3TeLqeau1ob17Y= Xref: csiph.com comp.lang.c:65785 Reinhardt Behm writes: > jacobnavia wrote: > >> FILE c:\lcc\include64\stdio.h 123 >> >> and when emitting the error message the compiler could improve it to >> >> "Missing Identifier 'FILE ' is not defined. >> Include stdio.h and proceed. >> >> This will cost me around 1 day development, and 1 day testing. Is that >> still possible for gcc and c++? >> >> I think that I could do that improvement to gcc's C front end, but the >> C++ front end? >> >> Impossible. > > True, it is impossible. > > You want the compiler to _your_ job to specify what has to be included. > From where should the compiler know what "FILE" means and where it is > defined? > > Instead of the usual definition in stdio.h "FILE" could be the definition of > a structure to hold the flight path of the New Horizon spacecraft. And this > definition is in a file that you not only forgot to include but even forgot > to download from that server in Mongolia which is only online when the moon > rises over the horizon. A compiler can easily recognize identifiers defined in the standard library and tailor its diagnostic messages to catch problems caused by using an identifier without #including the corresponding header. If FILE is used without a visible declaration, it's entirely reasonable for a compiler to suggest adding `#include `. Maybe FILE is really a type name defined in some application-specific header that you forgot to #include, but that's both unlikely and a bad idea, and if the compiler guesses wrong it's not likely to cause any real problems. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"