Quote:
Originally Posted by NevemTeve
1. Always declare your functions before you use them.
|
I think most of the responses in this thread are missing the question slightly... so let me elaborate.
====a.h====
void a(void);
===compiles without warning.c====
#include "a.h"
//Provide weak stub....
void __attribute__((weak)) a(void)
{
}
void b(void)
{
// Invoke a
a();
}
===compiles with warning.c====
#include "a.h"
void b(void)
{
// Invoke a
a();
}
// Get warning: weak declaration of ‘a’ after first use results in
unspecified behavior
void __attribute__((weak)) a(void)
{
}
Quote:
2. The compiler may generate different code if it knows that the called function is weak.
|
I guess is that is the heart of the question... why would it?