To which C language dialect do I have to change my Xcode settings that it will compile my code

So currently this is happening when I set my C language dialect to gnu11. Which one would I have to use for these errors to disappear?

Accepted Reply

I recommend that you fix this code rather than try to disable the compiler warnings it generates. This code seems to be use a pre-ANSI style of C. The problem with pre-ANSI C is that the calling conventions in modern ABIs need function prototypes so that the compiler can put parameters in the right place and get function results from the right place. Such calling conventions are fundamentally incompatible with pre-ANSI C.

Notably, the Apple silicon calling convention falls into this group.

To fix this code:

  • Add the static modifier to any function that’s internal to this file.

  • Add the extern modifier and a prototype to any function that can be called from outside this file.

  • In ANSI C, a function with no parameters must have a parameter list of (void).

  • For functions that return no value, change the result type to void.

So, assuming all of these functions are internal, your code would look like this:

static int noDistance(void)
{
    …
}

static void startKleiner(void)
{
    …
}

static void trennenInStationUndLinie(void)
{
    …
}

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

  • Thank you extremely much. This was VERY helpful. Have a wonderful day!

Add a Comment

Replies

I recommend that you fix this code rather than try to disable the compiler warnings it generates. This code seems to be use a pre-ANSI style of C. The problem with pre-ANSI C is that the calling conventions in modern ABIs need function prototypes so that the compiler can put parameters in the right place and get function results from the right place. Such calling conventions are fundamentally incompatible with pre-ANSI C.

Notably, the Apple silicon calling convention falls into this group.

To fix this code:

  • Add the static modifier to any function that’s internal to this file.

  • Add the extern modifier and a prototype to any function that can be called from outside this file.

  • In ANSI C, a function with no parameters must have a parameter list of (void).

  • For functions that return no value, change the result type to void.

So, assuming all of these functions are internal, your code would look like this:

static int noDistance(void)
{
    …
}

static void startKleiner(void)
{
    …
}

static void trennenInStationUndLinie(void)
{
    …
}

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

  • Thank you extremely much. This was VERY helpful. Have a wonderful day!

Add a Comment