Skip to content

bogus -Wmissing-prototypes warning with extern "C" function (fuzzer) #55018

@firewave

Description

@firewave

If you are writing a fuzzer the code will basically like this:

#include <cstddef>
#include <cstdint>

extern "C" int LLVMFuzzerTestOneInput(const uint8_t*, size_t)
{
    return 0;
}

But this code will produce a warning:

clang-13 -fsanitize=fuzzer -Weverything -o main main.cpp
main.cpp:4:16: warning: no previous prototype for function 'LLVMFuzzerTestOneInput' [-Wmissing-prototypes]
extern "C" int LLVMFuzzerTestOneInput(const uint8_t*, size_t)
               ^
main.cpp:4:12: note: declare 'static' if the function is not intended to be used outside of this translation unit
extern "C" int LLVMFuzzerTestOneInput(const uint8_t*, size_t)
           ^
           static
1 warning generated.

If you fix that warning it will obviously no longer link.

Metadata

Metadata

Assignees

No one assigned

    Labels

    compiler-rt:fuzzerquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions