3 ms·
g++ gives an error if you do things out of order. But what I meant is that this is still better than a regular function signature. ie: int f(int a, int b) cha
by CoolGuySteve 7y ago
g++ gives an error if you do things out of order. But what I meant is that this is still better than a regular function signature.
ie: int f(int a, int b) changed to f(int b, int a) works but the arguments will be wrong if the call site doesn't change.
f({ .a = 1, .b = 2}) will fail at the call site when the struct is changed to expect f({ .b = 2, .a = 1})
But yes, while ideally the order of declaration wouldn't matter, C++ is going the other way, being extremely strict about initialization order to avoid complex constructor errors. I wish POD types would be treated differently for those warnings/errors.
- alexhutcheson 7y agoMakes sense - I misunderstood what you meant by order. It’s good to know that g++ gives you an error if the designator are out of order - thanks for pointing that out.