Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #82730
| From | Muttley@dastardlyhq.com |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: 1.0 / 0.0 |
| Date | 2022-01-04 16:06 +0000 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <sr1ra6$fv7$1@gioia.aioe.org> (permalink) |
| References | (9 earlier) <squfd9$4mg$1@gioia.aioe.org> <sqv7dr$1d1$1@dont-email.me> <gyGAJ.134556$SR4.130385@fx43.iad> <sr1370$1nj$1@gioia.aioe.org> <qEZAJ.128744$g35.86167@fx11.iad> |
On Tue, 04 Jan 2022 15:24:06 GMT
scott@slp53.sl.home (Scott Lurndal) wrote:
>Muttley@dastardlyhq.com writes:
>>On Mon, 03 Jan 2022 17:40:28 GMT
>>scott@slp53.sl.home (Scott Lurndal) wrote:
>>>David Brown <david.brown@hesbynett.no> writes:
>>>>On 03/01/2022 10:24, Muttley@dastardlyhq.com wrote:
>>>
>>>>> Why on earth can't I just do:
>>>>>
>>>>> struct myclass
>>>>> {
>>>>> static int i = 123;
>>>>> };
>>>>>
>>>>> in the same way that const members are initialised? I've never seen a good
>
>>>>> reason why it must be this way and it makes for messy header files.
>>>>>
>>>>>
>>>>
>>>>struct myclass
>>>>{
>>>> inline static int i = 123;
>>>>};
>>>>
>>>>This has been valid since C++17, along with inline variables. (Why do
>>>>you need "inline" here? Good question, and I hope someone else can
>>>>give a good answer!)
>>>
>>>Probably for backward compatability. Note that historically C++ was
>>>translated to C then compiled (e.g. cfront). Trying to do the static
>>>initialization in the class definition would result in linker errors
>>>due to duplicate definitions of the static variable when the class
>>>definition is include by multiple compilation units. Hence the requirement
>>>to declare it in a single compilation unit.
>>
>>C++ hasn't been translated into C for 25 years at least. Keeping this
>syntatic
>>quirk for so long rather demonstrates the C++ committee are more interested
>in
>>adding shiny shiny "fun" stuff to the language that they find interesting
>>rather than improving it for normal developers.
>>
>
>Of course, they did "fix" it - in a backward compatible way - in C++17, right?
How exactly do you have backwards compatible new syntax?
And waiting until 2017 to (sort of) fix a rather basic syntatic fault doesn't
exactly suggest they have their finger on the pulse of C++ devs. But we knew
that anyway.
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
1.0 / 0.0 Bonita Montero <Bonita.Montero@gmail.com> - 2021-12-29 20:00 +0100
Re: 1.0 / 0.0 Jack Lemmon <invalid@invalid.net> - 2021-12-29 19:15 +0000
Re: 1.0 / 0.0 Bonita Montero <Bonita.Montero@gmail.com> - 2021-12-29 21:20 +0100
Re: 1.0 / 0.0 "james...@alumni.caltech.edu" <jameskuyper@alumni.caltech.edu> - 2021-12-29 13:08 -0800
Re: 1.0 / 0.0 "daniel...@gmail.com" <danielaparker@gmail.com> - 2021-12-29 20:37 -0800
Re: 1.0 / 0.0 Paavo Helde <eesnimi@osa.pri.ee> - 2021-12-30 17:25 +0200
Re: 1.0 / 0.0 "daniel...@gmail.com" <danielaparker@gmail.com> - 2021-12-30 08:55 -0800
Re: 1.0 / 0.0 Manfred <noname@add.invalid> - 2021-12-30 18:48 +0100
Re: 1.0 / 0.0 "daniel...@gmail.com" <danielaparker@gmail.com> - 2021-12-30 10:16 -0800
Re: 1.0 / 0.0 Manfred <noname@add.invalid> - 2021-12-30 20:02 +0100
Re: 1.0 / 0.0 Muttley@dastardlyhq.com - 2021-12-31 10:25 +0000
Re: 1.0 / 0.0 Manfred <noname@add.invalid> - 2021-12-31 18:34 +0100
Re: 1.0 / 0.0 Juha Nieminen <nospam@thanks.invalid> - 2022-01-03 06:21 +0000
Re: 1.0 / 0.0 red floyd <no.spam.here@its.invalid> - 2022-01-03 00:11 -0800
Re: 1.0 / 0.0 "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2022-01-03 09:28 +0100
Re: 1.0 / 0.0 Juha Nieminen <nospam@thanks.invalid> - 2022-01-03 08:36 +0000
Re: 1.0 / 0.0 Muttley@dastardlyhq.com - 2022-01-03 09:24 +0000
Re: 1.0 / 0.0 David Brown <david.brown@hesbynett.no> - 2022-01-03 17:14 +0100
Re: 1.0 / 0.0 Muttley@dastardlyhq.com - 2022-01-03 16:22 +0000
Re: 1.0 / 0.0 scott@slp53.sl.home (Scott Lurndal) - 2022-01-03 17:40 +0000
Re: 1.0 / 0.0 Muttley@dastardlyhq.com - 2022-01-04 09:15 +0000
Re: 1.0 / 0.0 scott@slp53.sl.home (Scott Lurndal) - 2022-01-04 15:24 +0000
Re: 1.0 / 0.0 Muttley@dastardlyhq.com - 2022-01-04 16:06 +0000
Re: 1.0 / 0.0 Juha Nieminen <nospam@thanks.invalid> - 2022-01-04 07:58 +0000
Re: 1.0 / 0.0 Muttley@dastardlyhq.com - 2022-01-04 09:17 +0000
Re: 1.0 / 0.0 Manfred <noname@add.invalid> - 2022-01-03 23:14 +0100
Re: 1.0 / 0.0 Öö Tiib <ootiib@hot.ee> - 2022-01-03 23:50 -0800
Re: 1.0 / 0.0 Manfred <noname@add.invalid> - 2022-01-04 10:42 +0100
Re: 1.0 / 0.0 Öö Tiib <ootiib@hot.ee> - 2022-01-04 10:15 -0800
Re: 1.0 / 0.0 Manfred <noname@invalid.add> - 2022-01-04 20:49 +0100
Re: 1.0 / 0.0 Öö Tiib <ootiib@hot.ee> - 2022-01-04 15:40 -0800
Re: 1.0 / 0.0 Juha Nieminen <nospam@thanks.invalid> - 2022-01-04 08:34 +0000
Re: 1.0 / 0.0 Manfred <noname@add.invalid> - 2022-01-04 10:47 +0100
Re: 1.0 / 0.0 Tim Rentsch <tr.17687@z991.linuxsc.com> - 2022-01-16 12:40 -0800
csiph-web