Isn't the c89 standard supposed to be consistent ?
I'm compiling with gcc -W -Wall -std=c89 -pedantic -O3
On macOS, gcc is an alias of clang it seems : gcc --version returns Apple clang version 14.0.0 (clang-1400.0.29.201). It gives no warnings about powf, and the program behaves as expected.
Whereas on linux it's the real deal. It gives all the errors / warnings expected and doesn't compile.
The specifications for the standard library of C89 include a
pow()function with arguments of typedoublethat returns adouble, but none for apowf()function. C99 addedpowf()as an analog that accepts arguments of typefloatand returns afloat.How different compilers for different machines handle that when asked to compile in a mode that requests conformance with a specific version of the language specification is specific to those compilers. That's all that really can be said about why you observe a difference.
But do note that the difference you observe might not be the difference you think you observe. If compiling in C89 mode means that no declaration of
powf()is provided by math.h then that does not imply that C89 programs that call that function will not compile. On the contrary, such programs should still compile, but their calls topowf()will produce undefined behavior, probably incorrect behavior, as a result of thepowf()function that is in fact present in the system libraries not having the signature that a C89 processor should infer from a call to that function when no prototype is in scope.The C89 standard is a singular document. It cannot fail to be consistent. But how different compilers implement c89 conformance modes is not consistent.