In hell.c
void myLocalFunc(){ printf("Hello hell\r\n"); }
In world.c
void myLocalFunc(){ printf("Hello world\r\n"); }
Because they are local functions only, i dont declare them in header files. But when i compile the project, it gives me "Multiple definition of 'myLocalFunc'" error message and also this one: "Multiple definition of 'myLocalFunc' (first defined here)".
What is my mistake here?
Replace it with
static void myLocalFunc(){ printf("Hello world\r\n"); }
Or, if you're using C++, you can also use an anonymous namespace like this:
namespace {
void myLocalFunc(){ printf("Hello world\r\n"); }
}
精彩评论