Xcode reports an implicit declaration of a function in C code
Implicit declaration of function 'foo' is invalid in C99Short answer
Clang saw a call to a function it has not been told about. Since Clang 16 this is an error in C99 and later, not a warning. Include the header that declares the function, or declare it yourself, and make sure the file is not compiled in a C mode that is older than the code expects.
Fix it fast
1Find out which cause you have
Read the full diagnostic: it names the function and the file. Then find where that function is declared in your project or the library.
grep -rn "foo(" --include=*.h Pods/ MyApp/ | head2Match what you see, then jump to its fix
- 1
The function exists in a header you did not import into this .c or .m fileThe header with the declaration is not includedFix - 2
Old third-party C code or a generated file that calls functions with no headerNo declaration exists because the code relies on old implicit behaviorFix - 3
A dependency you cannot edit fails on this diagnostic and no newer release existsYou need the old warning only for one vendor file, for nowFix
- 1
What does the error look like?
Implicit declaration of function 'foo' is invalid in C99
Cause 1 of 3
The header with the declaration is not included
1Check
In C99 and later every function must be declared before it is called. Clang 16 made -Wimplicit-function-declaration and -Wimplicit-int errors by default in C99, C11 and C17, and removed the implicit forms in C2x.
grep -rn "foo" --include=*.h . | head2Fix
Add the include (or the import in Objective-C) for the header that declares the function, at the top of the file that calls it.
#include "foo.h"
// Objective-C: #import "foo.h"3Verify
Build again; the diagnostic for that call is gone.
xcodebuild -project MyApp.xcodeproj -scheme MyApp buildConfirmed by releases.llvm.org
Cause 2 of 3
No declaration exists because the code relies on old implicit behavior
1Check
Old code often leaned on implicit declarations. Clang no longer accepts that by default. Search the source for the definition of the function.
grep -rn "foo(" --include=*.c . | head2Fix
Add a prototype above the first call, with the real return type and parameter types from the definition. For a file you cannot change, update the library to a version that fixes the declaration.
int foo(const char *name, int count);3Verify
Build the target and confirm the call compiles.
xcodebuild -project MyApp.xcodeproj -scheme MyApp buildConfirmed by releases.llvm.org
Cause 3 of 3
You need the old warning only for one vendor file, for now
1Check
Clang lets you map a diagnostic that is an error by default back to a warning with a pragma, in C code. It is a stopgap, because the call is still undeclared.
grep -rn "pragma clang diagnostic" MyApp/ | head2Fix
Wrap only the vendor include or file with the pragma, and plan to fix or replace the dependency.
#pragma clang diagnostic push
#pragma clang diagnostic warning "-Wimplicit-function-declaration"
#include "vendor_old.c"
#pragma clang diagnostic pop3Verify
The build passes with a warning instead of an error, and the warning appears only for that file.
xcodebuild -project MyApp.xcodeproj -scheme MyApp build 2>&1 | grep -i "implicit"Confirmed by clang.llvm.org
How do I stop it coming back?
- Treat these diagnostics as errors in new C code and keep headers next to their sources.
- Update third-party C dependencies to releases built for Clang 16 and newer.
- Do not use a blanket pragma or -w; narrow the exception to one file.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Related fixes
Mobile apps
Cannot change the App Privacy answers in App Store Connect
Publish Your App Privacy Responses?
Only the Account Holder, Admin and App Manager roles can answer the App Privacy questions.
2 causes, each with a fixMobile apps
App record creation fails because you lack permission
You cannot add a new app in App Store Connect as a Developer or limited user
Only the Account Holder, an Admin or an App Manager can create an app record, and Apple blocks it until the Account Holder has signed the latest agreement.
3 causes, each with a fixMobile apps
You cannot find the button to pull your app back from review
No 'remove this version from review' message appears on the version page
There is no button called Reject Binary.
3 causes, each with a fixMobile apps
Your Apple Account cannot sign in to App Store Connect
Sign-in to App Store Connect is refused for an account that should have access
App Store Connect does not open to every Apple Account.
3 causes, each with a fixMobile apps
Apple rejected the app under Guideline 4.3, Design: Spam
Guideline 4.3(b) - Design - Spam
Guideline 4.3 is Apple's duplicate rule.
5 causes, each with a fixMobile apps
App Store Connect rejects a screenshot because it has transparency
Images can't include alpha channels or transparencies.
App Store Connect does not accept screenshots that carry an alpha channel or transparent pixels.
2 causes, each with a fix