I guess you're missing something, here.
static?
Declaring a function static will make it "hidden" in its compilation unit. If you declare this static functions in a header, then all the compilation units units including this header will have their own copy of the function (and possibly, of the static variables inside).
This means that if you have a static function (or even a global object/variable), then this function will exist in each compilation unit (i.e. CPP file) that includes the header where this static function is declared. I have yet to see cases (but some rare debug corner cases) where this is something you want.
inline?
Declaring it inline makes it a candidate for inlining (not that it does not mean a lot nowadays in C++, as the compiler will inline or not, sometimes ignoring the fact the keyword inline is present or absent).
In a header, its has an interesting side effect: The inlined function can be defined multiple times in the same module, and the linker will simply join "them" into one (if they were not inlined for compiler's reason).
This has the advantage of "static" (i.e. it can be defined in a header) without its flaws (it exists at most once if it is not inlined)
static + inline?
Mixing inline and static will then have the consequences you described (even if the function is inlined, the static variable inside won't be, and you'll end with as much static variables as you have compilation units including the definition of your static functions).
Anyway, what's the point declaring your function static in C++?
Because it should be private? If so, don't declare it in a header (only in one CPP), or even better, use C++'s idiom for that (define it inside an anonymous namespace inside the CPP file).
(Note that I'm talking about functions, not methods: static methods have their uses in C++)
Answer to author's additionnal question
Since I wrote the question I tried it out with Visual Studio 2008. I tried to turn on all the options that make VS act in compliance with standards, but it's possible that I missed some. These are the results:
When the function is merely "inline", there is only one copy of the static variable.
When the function is "static inline", there are as many copies as there are translation units.
The real question is now whether things are supposed to be this way, or if this is an ideosyncracy of the Microsoft C++ compiler.
So I suppose you have something like that:
void doSomething()
{
static int value ;
}
You must realise that the static variable inside the function, simply put, a global variable hidden to all but the function's scope, meaning that only the function it is declared inside can reach it.
Inlining the function won't change anything:
inline void doSomething()
{
static int value ;
}
There will be only one hidden global variable. the fact the compiler will try to inline the code won't change the fact there is only one global hidden variable.
Now, if your function is declared static:
static void doSomething()
{
static int value ;
}
Then it is "private" for each compilation unit, meaning that every CPP file including the header where the static function is declared will have its own private copy of the function, including its own private copy of global hidden variable, thus as much variables as there are compilation units including the header.
Adding "inline" to a "static" function with a "static" variable inside:
inline static void doSomething()
{
static int value ;
}
has the same result than not adding this "inline" keyword, as far as the static variable inside is concerned.
So the behaviour of VC++ is correct, and you are mistaking the real meaning of "inline" and "static".