Possible Duplicate:
C/C++: Static function in header file, what does it mean?
When to put static function definitions in header files in C?
What are the pros and cons of using static function in header file?
Possible Duplicate:
C/C++: Static function in header file, what does it mean?
When to put static function definitions in header files in C?
What are the pros and cons of using static function in header file?
Supposing you implement it in the header file, each time your header is included, the function is going to be duplicated. This means heavier produced binary, bad practice and overall nightmare to debug and maintain.
If you just define it in the header, you need to implement in each C file.
EDIT
EDIT 2 Here is the kind of pitfall you can run into
static.h
#ifndef _STATIC_H_
#define _STATIC_H_
#include <stdio.h>
static void printer(void);
void nonStatic (void);
#endif
a.c
#include "static.h"
static void printer(void)
{
printf ("half the truth : 21\n");
}
int main (void) {
printer();
nonStatic();
}
b.c
#include <stdio.h>
#include "static.h"
static void printer (void)
{
printf("Truth : 42\n");
}
void nonStatic(void)
{
printf ("Non static\n");
printer();
}
Looking at this code, you call "printer" from 2 different locations, you got different behaviour:
D:\temp>gcc -o temp.exe a.c b.c && temp
half the truth : 21
Non static
Truth : 42
Obvious in this small example, really tricky when hidden in a big software