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


Groups > comp.lang.c > #142580

Re: C Translator

From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.c
Subject Re: C Translator
Date 2019-03-29 10:42 +0000
Organization A noiseless patient Spider
Message-ID <87y34yc67j.fsf@bsb.me.uk> (permalink)
References <Dr6nE.1476625$Xct1.1108593@fx12.am4> <xfdnE.427090$0_.110498@fx19.am4> <lnk1gia152.fsf@kst-u.example.com> <DufnE.1219230$OGY.973445@fx08.am4>

Show all headers | View raw


Bart <bc@freeuk.com> writes:

> Functions (in my world anyway) are of three kinds: local, exported,
> and imported, usually indicated in C by 'static', <nothing> and
> 'extern' respectively. Notice the last two are exclusive, so they
> shouldn't both have 'extern'.

I'm not exactly sure what your kinds are, but it looks likely that C's
view of functions is not the same as yours.  (I note that only because
it's of what follows -- I don't need to know how you view functions.)

> So, yes, it's incovenient due to C being so messy in not being able to
> cleanly specify this stuff.

You found some C code that did not cleanly specify the distinctions that
matter to you.  There's lots of messy C out there and almost all of it
won't meet your expectations.

> I mean, what does this mean in a program at module scope:

It's called file scope in C.

>   int abc;
>   ...
>   int abc;
>   ...
>   int abc;
>
> Is abc defined in this module or not?

Yes, it is.

> If it is, then it really needs to be initialised.

Yes, and it is.

> If it isn't, then because none is static, at least one needs to have
> 'extern'.

No.  You could find out what's needed by reading the language standard.

> In practice, if N modules contain those same uninitialised
> declarations,

That's fuzzy wording but it explains why you might have thought the
object defined above was not initialised.  Objects are (or are not)
initialised; declarations on the other hand might (or might not) contain
an initialiser.  The definitions above do not include an initialiser,
but the object is initialised.

> one implementation might assign ownership of the
> variable to one. Another might define multiple copies.

It might.  That situation is "undefined" and the implementation can do
what it likes.  This is for historical reasons.  C did not want to say
what a linker /must/ do in this situation since C often relied the
system's linker.  So it was left open.

This is not the first time I've written essentially the same thing in a
reply to you (I post mainly in case anyone else finds it useful).  But,
to be fair, you did say that did not want to learn anything more about C
quite a while ago, so I don't expect you to take any of it onboard.

> Aren't you lot embarrassed to be working with such a language?

No.  The fact that it is probably the single most important programming
language ever, softens the blow a bit.  It's also probably the most
widely implemented programming language.  That's likely to be why you
use it.

> What exactly is the 700 pages of Standard about if it doesn't even pin
> down such basics?

And yet I was able to answer your questions.  Where things are not pined
down it is almost always to give implementations some leeway.  That's
not a bad thing where you want fast code.

-- 
Ben.

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


Thread

C Translator Bart <bc@freeuk.com> - 2019-03-28 16:16 +0000
  Re: C Translator Bart <bc@freeuk.com> - 2019-03-29 00:01 +0000
    Re: C Translator Robert Wessel <robertwessel2@yahoo.com> - 2019-03-28 20:31 -0500
    Re: C Translator Keith Thompson <kst-u@mib.org> - 2019-03-28 19:02 -0700
      Re: C Translator Bart <bc@freeuk.com> - 2019-03-29 02:34 +0000
        Re: C Translator David Brown <david.brown@hesbynett.no> - 2019-03-29 10:58 +0100
          Re: C Translator Bart <bc@freeuk.com> - 2019-03-29 12:47 +0000
            Re: C Translator David Brown <david.brown@hesbynett.no> - 2019-03-29 14:57 +0100
              Re: C Translator Bart <bc@freeuk.com> - 2019-03-29 14:57 +0000
                Re: C Translator fir <profesor.fir@gmail.com> - 2019-03-29 15:08 -0700
                Re: C Translator fir <profesor.fir@gmail.com> - 2019-03-29 15:42 -0700
              Re: C Translator scott@slp53.sl.home (Scott Lurndal) - 2019-03-29 15:16 +0000
                Re: C Translator Bart <bc@freeuk.com> - 2019-03-29 15:30 +0000
                Re: C Translator fir <profesor.fir@gmail.com> - 2019-03-29 14:47 -0700
        Re: C Translator Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-03-29 10:42 +0000
          Re: C Translator Bart <bc@freeuk.com> - 2019-03-29 11:57 +0000
            Re: C Translator Bart <bc@freeuk.com> - 2019-03-29 13:04 +0000
            Re: C Translator David Brown <david.brown@hesbynett.no> - 2019-03-29 14:58 +0100
              Re: C Translator Bart <bc@freeuk.com> - 2019-03-29 14:29 +0000
                Re: C Translator Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-03-29 20:06 +0000
            Re: C Translator Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-03-29 20:02 +0000
              Re: C Translator Bart <bc@freeuk.com> - 2019-03-29 21:10 +0000
                Re: C Translator nobody@example.org (Scott) - 2019-03-30 04:52 +0000
                Re: C Translator Bart <bc@freeuk.com> - 2019-03-30 11:03 +0000
                Re: C Translator nobody@example.org (Scott) - 2019-03-30 16:17 +0000
                Re: C Translator Bart <bc@freeuk.com> - 2019-03-30 18:36 +0000
                Re: C Translator Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-03-30 20:32 +0000
                Re: C Translator Bart <bc@freeuk.com> - 2019-03-30 22:44 +0000
                Re: C Translator Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-03-31 03:23 +0100
                Re: C Translator Bart <bc@freeuk.com> - 2019-03-31 12:39 +0100
                Re: C Translator Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-03-31 15:07 +0100
                Re: C Translator Bart <bc@freeuk.com> - 2019-03-31 16:21 +0100
                Re: C Translator David Brown <david.brown@hesbynett.no> - 2019-03-31 21:19 +0200
                Re: C Translator Bart <bc@freeuk.com> - 2019-03-31 20:58 +0100
                Re: C Translator Ike Naar <ike@iceland.freeshell.org> - 2019-03-31 20:33 +0000
                Re: C Translator Bart <bc@freeuk.com> - 2019-03-31 22:06 +0100
                Re: C Translator Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-03-31 22:37 +0100
                Re: C Translator Bart <bc@freeuk.com> - 2019-03-31 23:33 +0100
                Re: C Translator Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-04-01 02:35 +0100
                Re: C Translator David Brown <david.brown@hesbynett.no> - 2019-04-01 11:33 +0200
                Re: C Translator David Brown <david.brown@hesbynett.no> - 2019-03-31 23:54 +0200
                Re: C Translator Bart <bc@freeuk.com> - 2019-04-01 02:16 +0100
                Re: C Translator Ike Naar <ike@iceland.freeshell.org> - 2019-04-01 06:42 +0000
                Re: C Translator David Brown <david.brown@hesbynett.no> - 2019-04-01 11:35 +0200
                Re: C Translator Bart <bc@freeuk.com> - 2019-04-01 16:54 +0100
                Re: C Translator Bart <bc@freeuk.com> - 2019-04-01 21:01 +0100
                Re: C Translator Keith Thompson <kst-u@mib.org> - 2019-04-01 13:41 -0700
                Re: C Translator Bart <bc@freeuk.com> - 2019-04-01 22:40 +0100
                Re: C Translator Keith Thompson <kst-u@mib.org> - 2019-04-01 16:25 -0700
                Re: C Translator Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-04-02 00:50 +0100
                Re: C Translator Keith Thompson <kst-u@mib.org> - 2019-04-01 17:45 -0700
                Re: C Translator Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-04-02 11:28 +0100
                Re: C Translator David Brown <david.brown@hesbynett.no> - 2019-04-02 13:18 +0200
                Re: C Translator Jorgen Grahn <grahn+nntp@snipabacken.se> - 2019-04-02 19:15 +0000
                Re: C Translator Bart <bc@freeuk.com> - 2019-04-02 21:14 +0100
                Re: C Translator Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-04-02 13:28 +0100
                Re: C Translator David Brown <david.brown@hesbynett.no> - 2019-04-02 10:49 +0200
                Re: C Translator Bart <bc@freeuk.com> - 2019-04-02 01:58 +0100
                Re: C Translator Keith Thompson <kst-u@mib.org> - 2019-04-01 19:13 -0700
                Re: C Translator Bart <bc@freeuk.com> - 2019-04-02 11:13 +0100
                Re: C Translator David Brown <david.brown@hesbynett.no> - 2019-04-02 13:49 +0200
                Re: C Translator Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2019-04-02 05:15 -0700
                Re: C Translator Bart <bc@freeuk.com> - 2019-04-02 14:50 +0100
                Re: C Translator David Brown <david.brown@hesbynett.no> - 2019-04-02 16:06 +0200
                Re: C Translator David Brown <david.brown@hesbynett.no> - 2019-04-02 16:05 +0200
                Re: C Translator Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-04-02 00:11 +0100
                Re: C Translator David Brown <david.brown@hesbynett.no> - 2019-04-02 10:35 +0200
                Re: C Translator Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-04-02 00:06 +0100
                Re: C Translator Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-03-31 21:36 +0100
                Re: C Translator Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-03-31 16:32 +0100
              Re: C Translator Bart <bc@freeuk.com> - 2019-03-30 00:37 +0000
                Re: C Translator Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-03-30 01:00 +0000
                Re: C Translator fir <profesor.fir@gmail.com> - 2019-03-30 03:37 -0700
                Re: C Translator fir <profesor.fir@gmail.com> - 2019-03-30 06:15 -0700
        Re: C Translator James Kuyper <jameskuyper@alumni.caltech.edu> - 2019-03-29 07:49 -0700

csiph-web