hirrolot / datatype99

Algebraic data types for C99
MIT License
1.38k stars 23 forks source link

The `derive` attribute has no postfixed version #12

Closed hirrolot closed 3 years ago

hirrolot commented 3 years ago

The derive attribute is not a macro name -- derive(...) is just a sequence of preprocessor lexemes fed into datatype(...). It turns out that this is a problem if a user of Datatype99 has a function-like macro named derive somewhere in their code. Even if a user does not specify derive(...) directly, Datatype99 specifies it by itself:

https://github.com/Hirrolot/datatype99/blob/f4fbffdbee852bfb7ac56de490dbdf0706473897/datatype99.h#L121

So I am pretty sure that releasing a new minor version with derive reified into a macro (derive/derive99) would not be a backwards compatibility breakage.

hirrolot commented 3 years ago

It is also worth noting that this change breaks functions named derive in user code. But the documentation didn't clarify the meaning of derive, therefore, it might be a macro or anything else, so I believe this change is backwards compatible, according to the documentation. Nonetheless, it can be easily fixed just by renaming the function or via DATATYPE99_NO_ALIASES.