#if LIB_VERSION_GE_3
lib_f (1, NULL);
#else
lib_f (1);
#endif
It can be difficult to do this with other mechanisms where the compiler is actually compiling and therefore type checking both branches.OCaml is a pretty rich language with many features, but we fall back on preprocessors like cppo (or even cpp) to deal with these kinds of cases.
Actually even in ISO C, the pre-processor is not required to be separated from the language, it is just kept that way in most compilers due to how C was originally implemented.
Even C++ is reducing the need to keep using the pre-processor with each ISO revision, in an ideal modern C++ world without C legacy baggage, the pre-processor will be so half assed like in C#. C++20 is already almost there.
It merely serves to alleviate an issue with a language limitation. And the library writers should have known better than to simply change the signature of an existing call.
(also this example reminds me of all the #ifndef/#define game that headers do which should have been built into the system in the first place)
I agree, unfortunately they do this and we have to cope with it.