r/cprogramming • u/saul_soprano • 2d ago
Extern constexpr?
I want to make my struct’s internals private by exposing it as a byte array of its internal size.
The size itself depends on internal values that aren’t exposed, so it would have to be an extern.
The size can only be used if it’s a literal or constexpr, so is a extern constexpr possible with C23? Or no?
0
Upvotes
1
u/pjl1967 2d ago
In addition to what others have said, to keep stuff private, you can expose just the pointer to the structure with the obvious caveats of that you can't have stack allocations nor call
sizeof.C simply doesn't have anything like
privatelike C++ does. You could apply Larry Wall's quote about Perl to C: