Re:Fun with C++26 reflection: Keyword Arguments
by tjalfi on Monday February 10, 2025 @09:43PM
(#43008346)
C++20 added designated initializers, so they're also an option.
[ Parent
| on HN ]
Re:Fun with C++26 reflection: Keyword Arguments
by anitil on Monday February 10, 2025 @09:58PM
(#43008435)
Oh I thought that was a C99 addition? It's been a while since I've used them.
Edit: struggling to find a source, though this GCC doc suggests it's C99 (but maybe that's only GCC?) - https://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html
Re:Fun with C++26 reflection: Keyword Arguments
by AlotOfReading on Monday February 10, 2025 @10:07PM
(#43008486)
It was C99. It took C++ 21 years to copy it.
Re:Fun with C++26 reflection: Keyword Arguments
by eqvinox on Tuesday February 11, 2025 @02:04AM
(#43009841)
It's been the primary and most annoying interop issue for us when we have to integrate C++ code into our primarily C codebase (= build some pieces of our code in C++, which necessarily has to interact with at least our header files).
(Second place: differences in available GCC/clang compiler extensions between C and C++ [our software does not support Windows/MSVC], third place: differences in what casts are permitted/how they are done)
Re:Fun with C++26 reflection: Keyword Arguments
by uecker on Tuesday February 11, 2025 @12:04PM
(#43015219)
My number one issue are VLA parameters
int foo(int N, char buf[N]);
which I like to use because they improve warning messages, but they are not accepted in C++.
Re:Fun with C++26 reflection: Keyword Arguments
by Cyph0n on Monday February 10, 2025 @10:07PM
(#43008487)
Well, C is not the same as C++. It even says in that doc that “this extension is not implemented in C++”.
Re:Fun with C++26 reflection: Keyword Arguments
by anitil on Monday February 10, 2025 @10:43PM
(#43008683)
Yeah sorry in my head I assumed that it would have been adopted
Re:Fun with C++26 reflection: Keyword Arguments
by pragma_x on Tuesday February 11, 2025 @09:40AM
(#43013200)
Even though you need to declare a struct for this (or other) functions to receive these fields, I feel like this is the cleanest approach. What I'm not sure about is if reference, value, or pointer is the best way to let the compiler optimize this.