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


Groups > comp.lang.c > #105488

Re: Problems with lcc-win32

From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: Problems with lcc-win32
Date 2017-03-06 08:37 -0800
Organization None to speak of
Message-ID <lnbmteicp2.fsf@kst-u.example.com> (permalink)
References <3cd2645c-a5a1-4284-8fb4-309e14ee4d8e@googlegroups.com> <o9i7to$1leq$1@gioia.aioe.org> <lnfuirhyc8.fsf@kst-u.example.com> <o9j9qr$slm$1@dont-email.me>

Show all headers | View raw


David Brown <david.brown@hesbynett.no> writes:

> On 06/03/17 04:35, Keith Thompson wrote:
>> jacob navia <jacob@jacob.remcomp.fr> writes:
>>> Le 05/03/2017 à 23:12, mertesthomas@gmail.com a écrit :
>> [...]
>>>> 3. A missing include file just triggers a warning. I had to change my test
>>>> programs to use something from the include file. This way I can recognize
>>>> when an include file is found by the C compiler.
>>>
>>> Well, that can be fixed easily. Will do next week. Transform the warning 
>>> in error. But...
>>>
>>> I am too liberal maybe? People like errors instead of warnings?
>>>
>>> What if you have an unused include missing? Nothing happens. Now all 
>>> those builds would crash. Is that better?
>>>
>>> What do you think?
>> [...]
>> 
>> In my opinion a missing include file should be a fatal error.  (If it's
>> unused, then don't include it.)  That's certainly what I'm used to, and
>> every compiler I've tried bails out immediately if a header is missing
>> (it won't even try to diagnose any following errors).  I suspect a lot
>> of users would be very surprised to see a missing include diagnosed with
>> a non-fatal warning.
>
> I agree entirely - I find it hard to imagine many use-cases for when a
> specified #include file does not exist and yet the compilation can
> reasonably continue without it.  I would say that when an include file
> is missing, the compiler should stop there and then with the error
> message - it is most likely to be an error on the part of the user.
>
> (Of course, it's fine to have a missing include if that directive is
> skipped by conditional compilation.)
>
>> 
>> Feel free to consider the fact that I'm not an lcc-win user in deciding
>> how to deal with this.
>> 
>> On the other hand, some kind of conditional include might be a useful
>> extension, perhaps something like:
>> 
>>     #include_if_exists <some_header.h>
>> 
>> and/or
>> 
>>     #if_header_exists <some_header.h>
>>     /* ... */
>>     #else
>>     /* ... */
>>     #endif
>> 
>
> I can see this second form having some merit, and it would provide more
> flexibility than the first suggestion.  It would let you write things like:
>
> #if_header_exists <super_enhanced_printf.h>
> 	#include <super_enhanced_printf.h>
> 	#define printf super_enhanced_printf
> #else
> 	#include <stdio.h>
> #endif
>
> However, if someone is going to implement such a feature, then I would
> strongly recommend implementing it as "__has_include" :
>
> #if __has_include(<super_enhanced_printf.h>)
> ...
>
> Several other compilers, including MSVC, gcc and clang, have this
> feature already - it makes sense to use the same syntax for the same
> feature.  Non-standard extensions should be standardised where possible!
>
> <http://clang.llvm.org/docs/LanguageExtensions.html#__has_include>

I didn't know about that.  Note that __has_include (along with the
related __has_include_next) is implemented in gcc, starting with
release 5 I think, but does not appear to be documented either in
the gcc manual or in the cpp manual.

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

Problems with lcc-win32 mertesthomas@gmail.com - 2017-03-05 14:12 -0800
  Re: Problems with lcc-win32 luser droog <luser.droog@gmail.com> - 2017-03-05 14:46 -0800
    Re: Problems with lcc-win32 gazelle@shell.xmission.com (Kenny McCormack) - 2017-03-05 22:57 +0000
    Re: Problems with lcc-win32 jacob navia <jacob@jacob.remcomp.fr> - 2017-03-06 00:49 +0100
      Re: Problems with lcc-win32 luser droog <luser.droog@gmail.com> - 2017-03-05 22:10 -0800
  Re: Problems with lcc-win32 BartC <bc@freeuk.com> - 2017-03-05 23:32 +0000
    Re: Problems with lcc-win32 jacob navia <jacob@jacob.remcomp.fr> - 2017-03-06 00:48 +0100
  Re: Problems with lcc-win32 jacob navia <jacob@jacob.remcomp.fr> - 2017-03-06 00:44 +0100
    Re: Problems with lcc-win32 BartC <bc@freeuk.com> - 2017-03-06 00:13 +0000
    Re: Problems with lcc-win32 Keith Thompson <kst-u@mib.org> - 2017-03-05 19:35 -0800
      Re: Problems with lcc-win32 David Brown <david.brown@hesbynett.no> - 2017-03-06 10:26 +0100
        Re: Problems with lcc-win32 James Kuyper <jameskuyper@verizon.net> - 2017-03-06 07:08 -0500
        Re: Problems with lcc-win32 Keith Thompson <kst-u@mib.org> - 2017-03-06 08:37 -0800
          Re: Problems with lcc-win32 David Brown <david.brown@hesbynett.no> - 2017-03-06 21:16 +0100
      Re: Problems with lcc-win32 jm.bourguet@gmail.com - 2017-03-06 06:54 -0800
        Re: Problems with lcc-win32 David Brown <david.brown@hesbynett.no> - 2017-03-06 17:18 +0100
          Re: Problems with lcc-win32 Keith Thompson <kst-u@mib.org> - 2017-03-06 08:42 -0800
            Re: Problems with lcc-win32 David Brown <david.brown@hesbynett.no> - 2017-03-06 21:19 +0100
          Re: Problems with lcc-win32 jm.bourguet@gmail.com - 2017-03-06 08:44 -0800
            Re: Problems with lcc-win32 David Brown <david.brown@hesbynett.no> - 2017-03-06 21:20 +0100
    Re: Problems with lcc-win32 mertesthomas@gmail.com - 2017-03-06 00:24 -0800
  Re: Problems with lcc-win32 jacobnavia <jacob@jacob.remcomp.fr> - 2017-03-06 18:15 +0100
    Re: Problems with lcc-win32 (trimmed) jacobnavia <jacob@jacob.remcomp.fr> - 2017-03-06 18:50 +0100
      Re: Problems with lcc-win32 (trimmed) mertesthomas@gmail.com - 2017-03-07 04:50 -0800
        Re: Problems with lcc-win32 (trimmed) jacobnavia <jacob@jacob.remcomp.fr> - 2017-03-07 14:54 +0100
          Re: Problems with lcc-win32 (trimmed) mertesthomas@gmail.com - 2017-03-07 06:20 -0800
            Re: Problems with lcc-win32 (trimmed) scott@slp53.sl.home (Scott Lurndal) - 2017-03-07 15:02 +0000
              Re: Problems with lcc-win32 (trimmed) mertesthomas@gmail.com - 2017-03-07 08:00 -0800
                Re: Problems with lcc-win32 (trimmed) jacobnavia <jacob@jacob.remcomp.fr> - 2017-03-07 20:30 +0100
                Re: Problems with lcc-win32 (trimmed) Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-03-08 01:06 +0000
                Re: Problems with lcc-win32 (trimmed) jacobnavia <jacob@jacob.remcomp.fr> - 2017-03-08 12:17 +0100
                Assigning a struct to an integer (Was: Problems with lcc-win32 (trimmed)) gazelle@shell.xmission.com (Kenny McCormack) - 2017-03-08 11:40 +0000
                Re: Problems with lcc-win32 (trimmed) Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-03-08 11:51 +0000
              Re: Problems with lcc-win32 (trimmed) Robert Wessel <robertwessel2@yahoo.com> - 2017-03-07 15:27 -0600
                Re: Problems with lcc-win32 (trimmed) scott@slp53.sl.home (Scott Lurndal) - 2017-03-08 13:50 +0000
                Re: Problems with lcc-win32 (trimmed) scott@slp53.sl.home (Scott Lurndal) - 2017-03-08 13:51 +0000

csiph-web