Does this error message concerning C prototype in Xcode beta make sense?

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.

Answered by DTS Engineer in 746387022

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"

Accepted Answer

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"

I'm running into the same issue, did you find a way around this?

I'm seeing this problem, among others, going from xcode 14.2 to 14.3. Is changing these lines of code to include "void" the best solution?

Is changing these lines of code to include "void" the best solution?

Yes. Or remove -Werror.

how to remove "-Werror."?

Hi. please any solution or how remove -Werror??? thanks

Does this error message concerning C prototype in Xcode beta make sense?
 
 
Q