Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

Xcode reports an implicit declaration of a function in C code

ErrorImplicit declaration of function 'foo' is invalid in C99

Short 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.

  • Applies to Xcode 26, Clang 16 and newer
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 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/ | head
  2. 2Match what you see, then jump to its fix

    1. 1The function exists in a header you did not import into this .c or .m fileThe header with the declaration is not includedFix
    2. 2Old 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. 3A dependency you cannot edit fails on this diagnostic and no newer release existsYou need the old warning only for one vendor file, for nowFix

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 . | head

2Fix

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 build

Confirmed by releases.llvm.org

Did this fix it?

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 . | head

2Fix

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 build

Confirmed by releases.llvm.org

Did this fix it?

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/ | head

2Fix

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 pop

3Verify

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

Did this fix it?

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

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 fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.