whitequark is a user on mastodon.social. You can follow them or interact with them if you have an account anywhere in the fediverse. If you don't, you can sign up here.

I'd just like to interject for moment. What you're refering to as C++, is in fact, C/C++, or as I've recently taken to calling it, C plus plus plus. C++ is not a programming language unto itself, but rather another free component of a fully functioning C system made useful by the C stdlibs, C preprocessor and vital build system components comprising a full language as defined by ANSI.

Many compiler users run a modified version of the C language every day, without realizing it. Through a peculia

@nanoha this is actually a good question, is it possible to meaningfully run a system on C++ but without C at all?

@munin @nanoha nope, common misconception! e.g. `new` is a valid variable name in C but not in C++

@whitequark @nanoha

Huh. I could have sworn you could get mixed C/C++ codebases in. Wonder why my head had that.

@nanoha @whitequark

....oh, I bet it's the linker letting you pull in stuff from C libraries, isn't it.

@munin @nanoha Both. You can mix C and C++ code in different compilation units as long as you tell C++ to use the C ABI (extern "C"), and *also* you can write polyglot code that compiles both as C and as C++ and does the same thing, but the latter is by no means completely trivial as the languages differ semantically quite a bit as well.

whitequark @whitequark

@nanoha @munin If you look into your system headers, you'll see chunks of
__cplusplus
extern "C" {

at the beginning and the closing version of it at the end; this is so that <stdio.h> links to the right (non-mangled) function names when you use it in a C++ compilation unit.

· Web · 0 · 1

@whitequark @nanoha

....wait, theoretically that means I could use the C versions of libraries in a C++ program?

@munin @nanoha Of course. Pretty much every C++ program in existence in fact does that, as it uses the C library, libc. The majority of platform libraries like winapi or gtk are also in C.

@munin @nanoha semi-related: TIL character literals in C (like 'a') have the type int

@whitequark @nanoha

....huh. I think I may have known that at some point, but now I'm wondering whether that applies outside the ASCII range.