0

I have noticed that many of the features new in C++17 were from C17. Is there any relation between the two standards? Are there any practical differences between the C functions and their C++ equivalents?

Swordfish
  • 12,971
  • 3
  • 21
  • 43
DexterHaxxor
  • 901
  • 6
  • 15
  • 13
    "many of the features new in C++17 were from C17" can you name some? I dont know any – 463035818_is_not_an_ai May 17 '19 at 12:32
  • 22
    Short answer: No. Long answer: No. – Swordfish May 17 '19 at 12:33
  • 2
    C++ kind of tries to maintain compatibility with C but AFIAK, no C17 features were added to C++17. Could you name a few? – NathanOliver May 17 '19 at 12:33
  • btw "I dont know any" in the sense of "I really dont know" not in the sense of "I believe you are talking bulls**t" ;) I am curious as I dont know any C – 463035818_is_not_an_ai May 17 '19 at 12:34
  • 2
    Given that [C++17 was finalized in Dec 2017](https://en.wikipedia.org/wiki/C18_(C_standard_revision)) and [C18 was published in June 2018](https://en.wikipedia.org/wiki/C18_(C_standard_revision)), I'd say basing C++17 on any part of C18 would be difficult. – Andrew Henle May 17 '19 at 12:37
  • 1
    They might share a common ancestor, but they are no longer based on each other. Would be a bit like saying that a mammal is based on a bird since they both evolved from fish. – Bathsheba May 17 '19 at 12:45
  • 3
    C17 doesn't have any significant new features. It's a bugfix release. – n. m. could be an AI May 17 '19 at 12:46
  • 1
    People are not addressing the questions asked in the question, just the title. The title: “Is C++17 based on C17?”: No, the formal text of the C++ specification refers to a prior version of the C standard, not C 2017/2018. The body: “Is there any relation between the two standards?”: I would guess members of the C++ committee had information about developments in C and thought about them, and that may have influenced their work. Also in the body: “Are there any practical differences between the C and C++ equivalents?”: I do not know offhand. Somebody should address this and the prior question. – Eric Postpischil May 17 '19 at 13:02
  • 3
    Actually, C 2018 is supposed to be merely technical corrections and clarifications to C 2011 (C 2018 Foreward 8), so there should not be anything in C 2018 that is not incorporated by C++’s reference to C 2011 except for those corrections and clarifications. – Eric Postpischil May 17 '19 at 13:05
  • 1
    @Bathsheba That's patently false. Species don't commonly copy traits and mammals rarely very exchange genes. Languages copy each others all the time and designers organize meetings for the purpose of making languages more similar. – curiousguy May 17 '19 at 22:04
  • 1
    @curiousguy: The eye has evolved at least 3 times independently. But I guess we can indulge ourselves in two comments each, this therefore being my last, as really we ought not be talking about evolutionary biology, interesting as it is. – Bathsheba May 18 '19 at 05:59

3 Answers3

9

Is C++17 based on C17?

No.

The normative reference for C++ as of the current working draft is C11.

If it is C11 now, then it was at latest C11 for C++17.

Here's a related proposal (though I'm not sure that it was exactly this proposal that was adopted).


I have noticed that many of the features new in C++17 were from C17.

I haven't. I haven't compared the two. If similar features were added to both, that's likely a co-incidence. However, since C17 was really just a "bug fix" update to C11, it seems unlikely.

Is there any relation between the two standards?

Not really, no. The two working groups will talk to each other, of course, but the two languages are independent.

Are there any practical differences between the C functions and their C++ equivalents?

Without specific examples I couldn't say, but again you should consider these to be separate and independent things.

C++ is only "based on" C in terms of the library and language features that it "inherits". However, note that this is not a wholesale import of C11 into C++17; that's not how it works.


By the way, although the term "C17" is an accepted (and widespread) name for it, and although its __STDC_VERSION__ macro is 201710L, it's really "C18" (and technically ISO/IEC 9899:2018).

(c.f. C++98's __cplusplus is 199711L; that's just how the timings work out sometimes, when publication stretches just slightly into a subsequent year after things like that have been agreed and frozen.)

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
  • 3
    No, it is C17, since the `__STDC_VERSION__` is `201710L`, which is all that matters. ISO publishing date is pretty irrelevant in general, they always lag behind. For example, the European or American standards could be named something like :2016 and the completely equivalent ISO standard could be named :2018. ISO haven't quite managed to standardize standards yet. – Lundin May 17 '19 at 13:20
  • 3
    @Lundin The `__STDC_VERSION__` needs to be consistent, and it usually vaguely matches the ISO document name (& date of publication), and it needs to numerically increase over time, but ultimately it is otherwise arbitrary. The true name of the standard is, er, the true name of the standard (and "C18" is simply a lexical abbreviation of that name). (See also, C++98 `__cplusplus` is _"199711L"_, and I'm sure you would not refer to that as C++97 as a result). I concede that C17 is the more widely-used term in this case, though; just how it turned out with the timings. – Lightness Races in Orbit May 17 '19 at 13:28
  • 3
    And as it happens, there's a C compiler named C18, for maximum confusion. But C18 doesn't support C18. So if more people would support C18, then C18 would be able to support C18. – Lundin May 17 '19 at 13:40
  • @Lundin I feel a tongue-twister coming on – Lightness Races in Orbit May 17 '19 at 13:41
  • @EricPostpischil Hah, I hadn't even noticed. Fixed (ish) – Lightness Races in Orbit May 17 '19 at 13:53
5

As of C++17, C++ standard refers to C11 (this proposal was adopted to ve the part of C++17 in 2016), not C17. But I wouldn't call it "based on".

Also, C++ and C standards are worked on by different working groups that don't really intersect, so the is no direct relation between them (although there is some effort to keep C and C++ features synchronized when it's easy to do so/makes sense).

Dan M.
  • 3,818
  • 1
  • 23
  • 41
  • 1
    @DanM. I didn't down vote you. Also, a proposal is not proof, its just people asking for a change. You should cite the standard to offer proof – NathanOliver May 17 '19 at 12:37
  • @LightnessRacesinOrbit I thought I did but SO messed up my formatting. – Dan M. May 17 '19 at 12:37
  • @formerlyknownas_463035818 the question is about C++17. – Dan M. May 17 '19 at 12:38
  • 1
    @DanM. There's a preview pane before you submit and you can read your markup before hitting submit. That way, you can see when you entered the wrong characters. – Lightness Races in Orbit May 17 '19 at 12:40
  • 2
    You guys (every body who answered or commented or voted for the question) are faster than it is humanly possible! What is your secret? – AKL May 17 '19 at 12:43
  • 2
    @AKL Well, that's because we are all bots programmed using C++ ;) – NathanOliver May 17 '19 at 12:44
  • 1
  • 2
    Re: "don't really intersect" -- on the contrary, there's a fair amount of intersection and a great deal of interaction between the two standards groups. – Pete Becker May 17 '19 at 13:12
  • @PeteBecker How many common members do C and C++ working groups share? Can't quickly find the WG14 member lest, but I remember them working in somewhat isolation until recently conscious attempts to unify some concepts (like new static zero-overhead exceptions) have been made. – Dan M. May 17 '19 at 13:30
  • @DanM. The number of names on common on two projects doesn't tell you anything about the amount of effort to keep these as close as possible in essential aspects. Compatibility of basic datatypes between C and C++ was always on the mind of ppl in the C++ committees (inter or national), even if they never directly interacted with the C committees. (And in some countries the C and C++ nat expert groups are one and the same.) – curiousguy May 21 '19 at 00:08
  • @curiousguy yet std::atomic happened. – Dan M. May 21 '19 at 00:46
  • @DanM. C++ atomics and C atomics use the same model. (Apparently C lacks carry_dependency.) – curiousguy May 21 '19 at 06:10
  • @curiousguy not really. They are not compatible. std::atomic_bool and atomic_bool are incompatible. There is no real way to interface C++11 atomics with C. – Dan M. May 21 '19 at 13:51
0

definitely not C and C++ are different language, they have totally different involving tree. by the way as long as I know it is c11