New compile error in Xcode 14.3: "Mixing declarations and code is incompatible with standards before C99"

Hi,

This is a weird one: We have a iOS project that has CorePlot as a sub-project that builds it's .a file that are linked with our binary. Everything worked fine on Xcode 14.2 but building the projects with 14.3 I get a massive amount of errors of this kind: "Mixing declarations and code is incompatible with standards before C99"

That relates to declarations that are not at the top a functions and that has been normal for as long as I have written Obj-C. It only happen in the CorePlot files not in our own. I can't find any special differences between the sub-project and the enclosing projects settings. Since it's has worked for years in all older versions of Xcode, I suspect this is something related to 14.3 and perhaps some older project formats?

Any ideas to try?

I've already messed with the compiler version settings, but both projects had GNU99 set, and changing it would did nothing...

Replies

I have had the same problem with an older build of Sparkle and have just now found the solution. You need to add this to your compiler flags (e. g. in the xcconfig file or under User-Defined in the build settings):

WARNING_CFLAGS = -Wno-declaration-after-statement

Here is more information about this (though I am still confused as I understand it should still be disabled by default): https://github.com/llvm/llvm-project/issues/53438

Yes!!!

Thank you, it worked! I did try that before in various places in Xcodes build-settings itself but it never worked. But with your tip of putting it into a xcconfig in the CorePlot project it worked. That is the most confusing thing: getting an error like this in one file and not in my own code that is written in similar way...