@jhx You asked for it, so I'll answer it:
Imho, C++ design is broken from the very beginning. It wanted to provide #OOP language constructs, still maintaining full #C compatibility (which already failed many years ago, cause the languages took different roads).
It combines #exceptions (IMHO generally a bad idea) with explicit resource management (an *awful* idea, forcing you to use #RAII which will in turn mandate creation of purely "technical" classes, just to manage resources).
It wanted #generics, but that's impossible without breaking C compatibility, so it came up with #templates, actually a #preprocessor on steroids.
Overloading also doesn't fit into the simple C library ABI (where #linker symbols are named just like the function), so it came up with "name mangling" ... which is especially horrific because it is *not* standardized.
Ah well, I could go on 😂
#oop #c #exceptions #raii #generics #Templates #preprocessor #linker
Another #preprocessor shortcoming.
"The #define directive in C and C99 is a preprocessor directive, which means it's handled before the actual compilation process. It does not respect scope ..."
So every `#define ...` you put somewhere must be named to be globally "valid", if you want to give it good names. There are just no local defines.
The X Macro: A Historic Preprocessor Hack https://hackaday.com/2023/03/16/the-x-macro-a-historic-preprocessor-hack/ #SoftwareDevelopment #SoftwareHacks #preprocessor #Featured #Interest #xmacro
#SoftwareDevelopment #SoftwareHacks #preprocessor #Featured #Interest #xmacro
OK people, I need a “proper” bibliographic #reference (book or journal article, if possible) for the C #preprocessor trick known as X-includes (including the same file multiple times with different defined macros as a sort of pseudo-template engine). Suggestions welcome.
I've written 2.6k lines of #GLSL #code, but due to using a #preprocessor to #include parts multiple times in a differently #define'd environment as an emulation of #templates, so the real code length is much longer and the #Mesa #compiler takes over 15 minutes to compile it.
Last time it compiled it gave me a blank screen, trying to debug it is painful with this turnaround.
#compiler #mesa #templates #define #include #preprocessor #code #glsl