Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #65785

Re: Error messages

From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: Error messages
Date 2015-07-17 07:54 -0700
Organization None to speak of
Message-ID <ln7fpykf6a.fsf@kst-u.example.com> (permalink)
References <mo9ik5$i9v$1@dont-email.me> <moa2c9$lir$1@dont-email.me>

Show all headers | View raw


Reinhardt Behm <rbehm@hushmail.com> writes:
> jacobnavia wrote:
>
>> FILE c:\lcc\include64\stdio.h 123
>> 
>> and when emitting the error message the compiler could improve it to
>> 
>> "Missing <stdio.h> 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 <stdio.h>`.  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  <http://www.ghoti.net/~kst>
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"

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Error messages jacobnavia <jacob@jacob.remcomp.fr> - 2015-07-17 02:36 +0200
  Re: Error messages Richard Heathfield <rjh@cpax.org.uk> - 2015-07-17 01:51 +0100
    Re: Error messages Keith Thompson <kst-u@mib.org> - 2015-07-16 18:24 -0700
      Re: Error messages Lőrinczy Zsigmond <nospam@for.me> - 2015-07-17 09:31 +0200
        Re: Error messages Richard Heathfield <rjh@cpax.org.uk> - 2015-07-17 08:35 +0100
          Re: Error messages glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-07-17 09:11 +0000
            Re: Error messages Richard Heathfield <rjh@cpax.org.uk> - 2015-07-17 10:30 +0100
            Re: Error messages Ian Collins <ian-news@hotmail.com> - 2015-07-17 21:44 +1200
              Re: Error messages Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-07-17 12:55 +0100
              Re: Error messages Melzzzzz <mel@zzzzz.com> - 2015-07-17 19:53 +0200
              Re: Error messages glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-07-17 17:55 +0000
                Re: Error messages James Kuyper <jameskuyper@verizon.net> - 2015-07-17 14:19 -0400
            Re: Error messages raltbos@xs4all.nl (Richard Bos) - 2015-07-19 21:44 +0000
        Re: Error messages gazelle@shell.xmission.com (Kenny McCormack) - 2015-07-17 07:38 +0000
          Re: Error messages Noob <root@127.0.0.1> - 2015-07-17 09:58 +0200
            Re: Error messages gazelle@shell.xmission.com (Kenny McCormack) - 2015-07-17 13:32 +0000
      Re: Error messages Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-07-18 11:13 +0100
  Re: Error messages James Kuyper <jameskuyper@verizon.net> - 2015-07-16 22:36 -0400
  Re: Error messages Reinhardt Behm <rbehm@hushmail.com> - 2015-07-17 13:05 +0800
    Re: Error messages jacobnavia <jacob@jacob.remcomp.fr> - 2015-07-17 09:48 +0200
      Re: Error messages David Kleinecke <dkleinecke@gmail.com> - 2015-07-17 19:23 -0700
        Re: Error messages Keith Thompson <kst-u@mib.org> - 2015-07-17 21:24 -0700
          Re: Error messages David Kleinecke <dkleinecke@gmail.com> - 2015-07-18 18:29 -0700
            Re: Error messages Keith Thompson <kst-u@mib.org> - 2015-07-18 20:59 -0700
              Re: Error messages David Kleinecke <dkleinecke@gmail.com> - 2015-07-19 19:22 -0700
            Re: Error messages David Brown <david.brown@hesbynett.no> - 2015-07-21 11:40 +0200
              Compiler conformance (Was: Error messages) gazelle@shell.xmission.com (Kenny McCormack) - 2015-07-21 11:40 +0000
                Re: Compiler conformance Noob <root@127.0.0.1> - 2015-07-21 14:01 +0200
                Re: Compiler conformance gazelle@shell.xmission.com (Kenny McCormack) - 2015-07-21 13:47 +0000
        Re: Error messages Reinhardt Behm <rbehm@hushmail.com> - 2015-07-18 13:38 +0800
    Re: Error messages Keith Thompson <kst-u@mib.org> - 2015-07-17 07:54 -0700
      Re: Error messages raltbos@xs4all.nl (Richard Bos) - 2015-07-19 22:00 +0000
        Re: Error messages Richard Damon <Richard@Damon-Family.org> - 2015-07-19 19:47 -0400
  Re: Error messages jacobnavia <jacob@jacob.remcomp.fr> - 2015-07-17 10:06 +0200
  Re: Error messages Bartc <bc@freeuk.com> - 2015-07-17 12:07 +0100
  Re: Error messages Noob <root@127.0.0.1> - 2015-07-17 13:14 +0200
    Re: Error messages Bartc <bc@freeuk.com> - 2015-07-17 12:40 +0100
  Re: Error messages gwowen <gwowen@gmail.com> - 2015-07-17 04:32 -0700
    Re: Error messages jacobnavia <jacob@jacob.remcomp.fr> - 2015-07-17 14:15 +0200
      Re: Error messages gwowen <gwowen@gmail.com> - 2015-07-17 05:25 -0700
        Re: Error messages Bartc <bc@freeuk.com> - 2015-07-17 13:34 +0100
          Re: Error messages Keith Thompson <kst-u@mib.org> - 2015-07-17 08:07 -0700
        Re: Error messages jacobnavia <jacob@jacob.remcomp.fr> - 2015-07-17 14:38 +0200
          Re: Error messages Martin Shobe <martin.shobe@yahoo.com> - 2015-07-17 08:50 -0500
            Re: Error messages jacobnavia <jacob@jacob.remcomp.fr> - 2015-07-17 16:08 +0200
              Re: Error messages Martin Shobe <martin.shobe@yahoo.com> - 2015-07-17 09:24 -0500
                Re: Error messages James Kuyper <jameskuyper@verizon.net> - 2015-07-17 12:26 -0400
                Re: Error messages Martin Shobe <martin.shobe@yahoo.com> - 2015-07-17 13:19 -0500
                Re: Error messages James Kuyper <jameskuyper@verizon.net> - 2015-07-17 14:28 -0400
                Re: Error messages James Kuyper <jameskuyper@verizon.net> - 2015-07-17 14:43 -0400
                Re: Error messages Bartc <bc@freeuk.com> - 2015-07-17 20:31 +0100
                Re: Error messages Martin Shobe <martin.shobe@yahoo.com> - 2015-07-18 08:41 -0500
                Re: Error messages David Brown <david.brown@hesbynett.no> - 2015-07-21 12:25 +0200
                Re: Error messages James Kuyper <jameskuyper@verizon.net> - 2015-07-21 13:20 -0400
                Re: Error messages David Brown <david.brown@hesbynett.no> - 2015-07-22 00:05 +0200
          Re: Error messages Noob <root@127.0.0.1> - 2015-07-17 16:16 +0200
            Re: Error messages doctor@doctor.nl2k.ab.ca (The Doctor) - 2015-07-17 14:49 +0000
              Re: Error messages Noob <root@127.0.0.1> - 2015-07-17 20:02 +0200
                Re: Error messages The Doctor <doctor@doctor.nl2k.ab.ca> - 2015-07-17 22:24 +0000
                Re: Error messages Noob <root@127.0.0.1> - 2015-07-20 10:46 +0200
                Re: Error messages doctor@doctor.nl2k.ab.ca (The Doctor) - 2015-07-20 14:59 +0000
          Re: Error messages Keith Thompson <kst-u@mib.org> - 2015-07-17 08:25 -0700
      Re: Error messages raltbos@xs4all.nl (Richard Bos) - 2015-07-19 22:07 +0000
  Re: Error messages Ed Prochak <edprochak@gmail.com> - 2015-07-17 20:11 -0700

csiph-web