|
|
|
|
|
by quelsolaar
606 days ago
|
|
This is one of the very rare cases in C where something is technically Undefined Behaviour, but in practice works and is recommended. The typedef struct trick, is very common idiom that creates _more_ safety, not less. All reasonable compilers should (and do) support this. It is sad that the ISO standard is not in line with reality at all times. (I say that as a member of the wg14 and the UB study group) I Recommend Daniel keep his typedef struct definition, and then have an ifdef to revert to the void definition for when Clang does its UB sanitizer. While checking for prototype discrepancies is a very good thing to automate, Clang should add an exception for this. |
|
Given:
This is perfectly fine: This is not: