My project has GoogleDataTransport pod dependency. When compiling with Xcode 14.3 beta (14E5197f), an error message saying that
A function declaration without a prototype is deprecated in all versions of C [-Werror, -Wstrict-prototypes]
appears on this line
GDTCORNetworkType GDTCORNetworkTypeMessage(){
(github). After changing to
GDTCORNetworkType GDTCORNetworkTypeMessage(void)
the project compiled successfully.
I am not particularly knowledgeable in C or Obj-C, but it seems to me that the GoogleDataTransport library correctly "declares" the function in the .h file (github). However, the error message still goes to the "definition" of function.
I am wondering if I should file a bug report to the GoogleDataTransport team or the Xcode team, or if there is something I should fix.
I've checked that my Xcode 14.2 has the same -Wstrict-prototypes
flag set, but no error. (Build Settings > Strict Prototypes, is it?)
Thanks for any help and information.
The original code would be correct C++ but in C you have to have the void
. The distinguishes a prototype for a function with no parameters:
GDTCORNetworkType GDTCORNetworkTypeMessage(void);
from a forward declaration that says nothing about the parameters:
GDTCORNetworkType GDTCORNetworkTypeMessage();
The interesting thing is that they have this right in the header it’s only a problem in the implementation.
ps ISTR than the C2x folks are planning to remove support for the old syntax, bringing C into line with C++ in this regard. I’m not tracking that effort closely myself but check out the links under Remove K&R function definitions/declarations on this page.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"