While it's not great, my recommendation would be to provide a
declaration within the same source file. The warning is generally
about defining a function with extern linkage without having
previously declared a prototype, which can be dangerous when there's
other callers in other translation units as they would have to match
the prototype without any compiler checks. The compiler can't know
when looking in isolation at one translation unit that the only
callers are assembler.
See for example stpcpy in lib/string.c:
290 char *stpcpy(char *__restrict__ dest, const char *__restrict__
src);
291 char *stpcpy(char *__restrict__ dest, const char *__restrict__
src)
292 {
...
It has extern linkage but we don't really want people to call it, so
the prototype is provided within the TU to shut up
-Wmissing-prototypes. I'd argue we should do the same thing to fix
-Wmissing-prototypes for functions who are only called from assembler.
You might think "that's stupid" and I wouldn't disagree, but that's
one of the ways to resolve -Wmissing-prototypes:
1. use static linkage if no callers exist outside of the TU (does not
apply here, we have external callers), or
2. provide a declaration in a header so other C callers don't mess up
the prototype (does not apply here, we don't have external C callers),
or
3. provide a declaration in the same TU
(4. don't do W=1 builds. :P)
While it may be painful/weird for this case, making this TU
-Wmissing-prototypes clean allows folks to tackle the above 3 cases
throughout the tree.
> --
> You received this message because you are subscribed to the Google Groups "Clang Built Linux" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
clang-built-li...@googlegroups.com.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/clang-built-linux/8d7aab68fd0d0a5d3ee1e99088e9a68e%40kernel.org.
--
Thanks,
~Nick Desaulniers