I am currently using Xcode 4, and in my .pch file I have this macro:
#define localize(s) NSLocalizedString((s), nil)
.
When I try to use this macro in some .m file, I receive this warning: Implicit declaration of function 'localize' is invalid in C99
.
This code compiles without a problem, but how can I fix this so I don't get a warning?
I had this problem because I accidentally imported CocoaLumberjack like this:
Apparently the CocoaLumberjack team modularized the code some more; and macros like
DDLogError
are now defined separately in their own header file.I replaced the import statement with this and the error went away:
Another "foolish" mistake I ran into was the fact that my DLog was defined in the prefix header of the iOS target, so I had to copy it over to the prefix of the OSX target, as well...
I had this problem when I did a global replace of NSLog with DLog. I foolishly included the
statements, so I ended up with
which caused the warnings, and a linker error.
Implicit function declarations are those that the compiler sees the first time used as a function call (as opposed to those where a prototype or the function definition is seen first).
Apparently your code used
localize(foo)
but the macro definition was not visible. Possible reasons: you forgot to#include
the file containing thelocalize
macro or the precompilation of headers went south an did not include thelocalize
macro so it was left unexpanded.In my case only one file was giving this error. Turned out that I added it to the project's tests target membership (in the File Inspector on the right).