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


Groups > comp.lang.c > #103867

Re: Is 'extern' necessary?

From BartC <bc@freeuk.com>
Newsgroups comp.lang.c
Subject Re: Is 'extern' necessary?
Date 2017-02-14 11:42 +0000
Organization A noiseless patient Spider
Message-ID <o7uqci$bg$1@dont-email.me> (permalink)
References (5 earlier) <ln7f4ut1va.fsf@kst-u.example.com> <o7t0ns$pnt$1@dont-email.me> <o7tfl8$lta$1@dont-email.me> <o7tkra$4al$1@dont-email.me> <o7uf0l$s1d$1@dont-email.me>

Show all headers | View raw


On 14/02/2017 08:28, David Brown wrote:
> On 14/02/17 02:02, BartC wrote:
>> On 13/02/2017 23:33, David Brown wrote:
>>> On 13/02/17 20:19, BartC wrote:
>>
>>>> It's a mystery why gcc-related headers seem to be so full of junk
>>>> compared with those of other compilers.
>>>
>>> Basically, what you are saying is "I don't understand this.  Therefore
>>> it must be junk".  I don't know whether you are too lazy to look it up,
>>
>> Why would I want to look it up?
>
> You must have had some interest in the details to look up the function's
> declaration in the header file - otherwise you would do what everyone
> else does, and use a more practical reference for the vsnprintf
> function, such as:
>
> <http://en.cppreference.com/w/c/io/vfprintf>
>
> So you are interested in how it is declared, yet now you are saying that
> you are not interested in what these details mean.

You should have read from further up the thread. I was investigating the 
use of 'extern' in various headers, and came across this.

It's like looking to see what kind of plugs are used in the sockets for 
various appliances, and coming across various 'christmas tree' 
arrangements with a dozen plugs plugged into one socket via multiple 
adaptors. You're not interested in what those extra plugs are for, only 
that it looks wrong.

>> Look at the lccwin or MSDN versions
>> below; /that's/ how you want these things expressed. Short and sweet. (I
>> don't want to think about what your own headers look like if you think
>> this is reasonable.)
>
> I don't have lccwin or MSDN, and have no interest in them - so no, I
> won't look that up.  You posted lccwin's version and it is far inferior
> for a library call.  It does not follow the standards (at least, not C99
> onwards),

Actually it's closer to what is given in the C standard than MingW's 
version.

  it does not name the parameters,

What's the purpose of that? If you say human documentation, then you're 
having a laugh. For some reason or other, they're putting half of the 
gubbins needed to implement it into the public interface.

  it provides no extra
> information to the compiler for optimisation usage (maybe lccwin simply
> does not have the same kind of optimisations),

This is at odds with what you've always said in the past about keeping 
explicit optimisation hints out of the source code, and letting the 
compiler just do its job.

  and it does not provide
> information to allow the kind of extremely useful format checking
> features of gcc.

I've already said that lccwin does exactly the same kind of format-checking.

> Standard library code is part of the implementation.  Even if it is
> developed separately from the compiler, it is still in close cooperation
> with the compiler.

"The" compiler? I thought such libraries were completely independent 
from any one compiler and were all interchangable?

Or you finally admitting that perhaps the MingW library /is/ really 
designed to work with gcc?


> The "vsnprintf" function is defined in the standard - the compiler knows
> what it should do, and can check the format string.  Whether it does
> that or not, I don't know.

So what's the point of the 'format' stuff then in the MingW code?

> int main(void) {
>   int a = 1;
>   const char* s = "Hello";
>   printf("Text: %s Data: %i\n", a, s);
> }
>
> With -Wall, gcc will warn that "%s" expects an argument of type "char*",
> but argument 2 has type "int".
>
> Does lccwin do that kind of checking?

lccwin gives me this with default options:

Warning c.c: 5  printf argument mismatch for format s. Expected char 
pointer got int
Warning c.c: 5  printf argument mismatch for format i. Expected int got 
pointer to char

gcc says nothing with default options. gcc -pedantic-errors says 
nothing. I have to use one of the -Wxxx options to get it to report it. 
So not only do I need the macguffin in the header file, I need a 
counterpart in the compiler options.

(Actually I tried to comment out the format attribute stuff from stdio.h 
to see if gcc still managed it. But it's so complicated I can hardly 
find the printf declaration. I completely commented out what looks like 
the one, and it still worked. It didn't even give an 'implicit 
declaration of printf' warning. So it's seeing it somewhere, but where? 
Hiding the stdio.h file did give an error about not finding stdio.h, so 
it was the right file; it wasn't sneakily using a version elsewhere.

THIS is what it's all about; when things get sticky enough that you have 
to start investigating things, then gcc or anything associated with it 
makes it much harder than with any other compiler (msvc excepted).

But perhaps that's to be expected with a compiler that chooses path 
names so difficult to type that you usually have to copy&paste:

   \tdm\x86_64-w64-mingw32\include

and with a back-up include path for the standard headers it can't find 
there:

  \tdm\lib\gcc\x86_64-w64-mingw32\5.1.0\include)

   As I say, it is perfectly
> possible for the compiler to manage this without it being in the header.

You make it sound like a dog walking on its hind legs. Of course it can 
do it if a compiler 'knows' about *printf functions.


-- 
bartc

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


Thread

Is 'extern' necessary? BartC <bc@freeuk.com> - 2017-02-10 17:16 +0000
  Re: Is 'extern' necessary? Keith Thompson <kst-u@mib.org> - 2017-02-10 09:33 -0800
    Re: Is 'extern' necessary? BartC <bc@freeuk.com> - 2017-02-10 18:41 +0000
      Re: Is 'extern' necessary? Keith Thompson <kst-u@mib.org> - 2017-02-10 12:09 -0800
        Re: Is 'extern' necessary? BartC <bc@freeuk.com> - 2017-02-10 20:29 +0000
          Re: Is 'extern' necessary? Keith Thompson <kst-u@mib.org> - 2017-02-10 13:26 -0800
            Re: Is 'extern' necessary? BartC <bc@freeuk.com> - 2017-02-10 22:56 +0000
              Re: Is 'extern' necessary? jameskuyper@verizon.net - 2017-02-10 20:19 -0800
                Re: Is 'extern' necessary? "James R. Kuyper" <jameskuyper@verizon.net> - 2017-02-11 09:53 -0500
              Re: Is 'extern' necessary? Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-13 05:19 -0800
      Re: Is 'extern' necessary? jameskuyper@verizon.net - 2017-02-10 12:09 -0800
        Re: Is 'extern' necessary? BartC <bc@freeuk.com> - 2017-02-10 20:50 +0000
          Re: Is 'extern' necessary? supercat@casperkitty.com - 2017-02-10 13:09 -0800
          Re: Is 'extern' necessary? Keith Thompson <kst-u@mib.org> - 2017-02-10 13:33 -0800
          Re: Is 'extern' necessary? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-10 23:23 +0000
            Re: Is 'extern' necessary? BartC <bc@freeuk.com> - 2017-02-10 23:35 +0000
              Re: Is 'extern' necessary? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-11 00:34 +0000
            Re: Is 'extern' necessary? David Brown <david.brown@hesbynett.no> - 2017-02-13 12:41 +0100
              Re: Is 'extern' necessary? BartC <bc@freeuk.com> - 2017-02-13 13:14 +0000
                Re: Is 'extern' necessary? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-13 14:05 +0000
                Re: Is 'extern' necessary? jameskuyper@verizon.net - 2017-02-13 07:49 -0800
          Re: Is 'extern' necessary? jameskuyper@verizon.net - 2017-02-10 19:33 -0800
            Re: Is 'extern' necessary? supercat@casperkitty.com - 2017-02-11 09:41 -0800
              Re: Is 'extern' necessary? Keith Thompson <kst-u@mib.org> - 2017-02-11 10:19 -0800
                Re: Is 'extern' necessary? "James R. Kuyper" <jameskuyper@verizon.net> - 2017-02-11 13:39 -0500
                Re: Is 'extern' necessary? supercat@casperkitty.com - 2017-02-12 10:10 -0800
      Re: Is 'extern' necessary? Andrey Tarasevich <andreytarasevich@hotmail.com> - 2017-02-10 14:59 -0800
      Re: Is 'extern' necessary? David Brown <david.brown@hesbynett.no> - 2017-02-13 12:33 +0100
  Re: Is 'extern' necessary? Siri Cruise <chine.bleu@yahoo.com> - 2017-02-10 09:35 -0800
    Re: Is 'extern' necessary? Keith Thompson <kst-u@mib.org> - 2017-02-10 12:12 -0800
  Re: Is 'extern' necessary? jameskuyper@verizon.net - 2017-02-10 10:38 -0800
  Re: Is 'extern' necessary? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-10 21:10 +0000
    Re: Is 'extern' necessary? supercat@casperkitty.com - 2017-02-10 13:25 -0800
  Re: Is 'extern' necessary? Andrey Tarasevich <andreytarasevich@hotmail.com> - 2017-02-10 14:53 -0800
    Re: Is 'extern' necessary? Andrey Tarasevich <andreytarasevich@hotmail.com> - 2017-02-10 15:06 -0800
    Re: Is 'extern' necessary? BartC <bc@freeuk.com> - 2017-02-10 23:24 +0000
      Re: Is 'extern' necessary? Ian Collins <ian-news@hotmail.com> - 2017-02-11 12:34 +1300
        Re: Is 'extern' necessary? David Brown <david.brown@hesbynett.no> - 2017-02-13 13:14 +0100
          Re: Is 'extern' necessary? GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-02-13 13:44 +0100
            Re: Is 'extern' necessary? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-13 14:13 +0000
            Re: Is 'extern' necessary? David Brown <david.brown@hesbynett.no> - 2017-02-13 15:16 +0100
              Re: Is 'extern' necessary? GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-02-13 17:24 +0100
                Re: Is 'extern' necessary? "James R. Kuyper" <jameskuyper@verizon.net> - 2017-02-13 14:24 -0500
                Re: Is 'extern' necessary? David Brown <david.brown@hesbynett.no> - 2017-02-13 23:29 +0100
            Re: Is 'extern' necessary? Keith Thompson <kst-u@mib.org> - 2017-02-13 11:06 -0800
            Re: Is 'extern' necessary? Andrey Tarasevich <andreytarasevich@hotmail.com> - 2017-02-13 11:15 -0800
          Re: Is 'extern' necessary? "James R. Kuyper" <jameskuyper@verizon.net> - 2017-02-13 11:48 -0500
            Re: Is 'extern' necessary? supercat@casperkitty.com - 2017-02-13 09:03 -0800
            Re: Is 'extern' necessary? David Brown <david.brown@hesbynett.no> - 2017-02-13 23:37 +0100
      Re: Is 'extern' necessary? Andrey Tarasevich <andreytarasevich@hotmail.com> - 2017-02-10 15:40 -0800
      Re: Is 'extern' necessary? Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-13 05:09 -0800
        Re: Is 'extern' necessary? BartC <bc@freeuk.com> - 2017-02-13 13:46 +0000
          Re: Is 'extern' necessary? Keith Thompson <kst-u@mib.org> - 2017-02-13 09:52 -0800
            Re: Is 'extern' necessary? BartC <bc@freeuk.com> - 2017-02-13 19:19 +0000
              Re: Is 'extern' necessary? Keith Thompson <kst-u@mib.org> - 2017-02-13 11:34 -0800
                Re: Is 'extern' necessary? BartC <bc@freeuk.com> - 2017-02-13 20:13 +0000
              Re: Is 'extern' necessary? Andrey Tarasevich <andreytarasevich@hotmail.com> - 2017-02-13 13:11 -0800
              Re: Is 'extern' necessary? David Brown <david.brown@hesbynett.no> - 2017-02-14 00:33 +0100
                Re: Is 'extern' necessary? BartC <bc@freeuk.com> - 2017-02-14 01:02 +0000
                Re: Is 'extern' necessary? David Brown <david.brown@hesbynett.no> - 2017-02-14 09:28 +0100
                Re: Is 'extern' necessary? Robert Wessel <robertwessel2@yahoo.com> - 2017-02-14 03:31 -0600
                Re: Is 'extern' necessary? BartC <bc@freeuk.com> - 2017-02-14 11:42 +0000
                Re: Is 'extern' necessary? David Brown <david.brown@hesbynett.no> - 2017-02-14 13:29 +0100
                Re: Is 'extern' necessary? supercat@casperkitty.com - 2017-02-14 05:16 -0800
                Re: Is 'extern' necessary? David Brown <david.brown@hesbynett.no> - 2017-02-14 14:51 +0100
                Re: Is 'extern' necessary? supercat@casperkitty.com - 2017-02-14 07:24 -0800
                Re: Is 'extern' necessary? David Brown <david.brown@hesbynett.no> - 2017-02-14 21:35 +0100
                Re: Is 'extern' necessary? James Kuyper <jameskuyper@verizon.net> - 2017-02-14 15:53 -0500
                Re: Is 'extern' necessary? David Brown <david.brown@hesbynett.no> - 2017-02-15 09:31 +0100
                Re: Is 'extern' necessary? "James R. Kuyper" <jameskuyper@verizon.net> - 2017-02-15 11:36 -0500
                Re: Is 'extern' necessary? Keith Thompson <kst-u@mib.org> - 2017-02-15 09:12 -0800
                Re: Is 'extern' necessary? "James R. Kuyper" <jameskuyper@verizon.net> - 2017-02-15 12:58 -0500
                Re: Is 'extern' necessary? supercat@casperkitty.com - 2017-02-15 10:01 -0800
                Re: Is 'extern' necessary? jameskuyper@verizon.net - 2017-02-15 10:55 -0800
                Re: Is 'extern' necessary? supercat@casperkitty.com - 2017-02-15 11:42 -0800
                Re: Is 'extern' necessary? jameskuyper@verizon.net - 2017-02-15 12:28 -0800
                Re: Is 'extern' necessary? supercat@casperkitty.com - 2017-02-15 13:58 -0800
                Re: Is 'extern' necessary? Keith Thompson <kst-u@mib.org> - 2017-02-14 08:54 -0800
                Re: Is 'extern' necessary? Keith Thompson <kst-u@mib.org> - 2017-02-14 08:51 -0800
                Re: Is 'extern' necessary? Richard Heathfield <rjh@cpax.org.uk> - 2017-02-14 17:32 +0000
                Re: Is 'extern' necessary? Gareth Owen <gwowen@gmail.com> - 2017-02-14 17:45 +0000
                Re: Is 'extern' necessary? David Brown <david.brown@hesbynett.no> - 2017-02-14 21:38 +0100
                Re: Is 'extern' necessary? BartC <bc@freeuk.com> - 2017-02-14 23:26 +0000
                Re: Is 'extern' necessary? Keith Thompson <kst-u@mib.org> - 2017-02-14 16:33 -0800
                Re: Is 'extern' necessary? BartC <bc@freeuk.com> - 2017-02-15 00:47 +0000
                Re: Is 'extern' necessary? Jean-Marc Bourguet <jm@bourguet.org> - 2017-02-14 18:17 +0100
                Re: Is 'extern' necessary? Keith Thompson <kst-u@mib.org> - 2017-02-14 09:47 -0800
                Re: Is 'extern' necessary? BartC <bc@freeuk.com> - 2017-02-14 18:36 +0000
                Re: Is 'extern' necessary? jameskuyper@verizon.net - 2017-02-14 11:20 -0800
                Re: Is 'extern' necessary? supercat@casperkitty.com - 2017-02-14 11:42 -0800
                Re: Is 'extern' necessary? BartC <bc@freeuk.com> - 2017-02-14 20:22 +0000
                Re: Is 'extern' necessary? Robert Wessel <robertwessel2@yahoo.com> - 2017-02-14 17:58 -0600
                Re: Is 'extern' necessary? BartC <bc@freeuk.com> - 2017-02-15 01:29 +0000
                Re: Is 'extern' necessary? Robert Wessel <robertwessel2@yahoo.com> - 2017-02-16 05:02 -0600
                Re: Is 'extern' necessary? BartC <bc@freeuk.com> - 2017-02-16 11:38 +0000
                Re: Is 'extern' necessary? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-16 14:37 +0000
                Re: Is 'extern' necessary? BartC <bc@freeuk.com> - 2017-02-16 15:43 +0000
                Re: Is 'extern' necessary? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-16 16:08 +0000
                Re: Is 'extern' necessary? GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-02-16 18:42 +0100
                Re: Is 'extern' necessary? David Brown <david.brown@hesbynett.no> - 2017-02-15 09:47 +0100
                Re: Is 'extern' necessary? Robert Wessel <robertwessel2@yahoo.com> - 2017-02-16 05:05 -0600
          Re: Is 'extern' necessary? Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-15 16:53 -0800
    Re: Is 'extern' necessary? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-10 23:55 +0000
  Re: Is 'extern' necessary? Les Cargill <lcargill99@comcast.com> - 2017-02-10 19:24 -0600
  Re: Is 'extern' necessary? void <nathan.gothier@gmail.com> - 2017-02-11 03:17 -0800

csiph-web