I have a function that is declared and defined in a header file. This is a problem all by itself. When that function is not inlined, every translation unit that uses that header gets a copy of the function, and when they are linked together there are duplicated.
I've "fixed" that by making the function inline
, but I'm afraid that this is a fragile solution because as far as I know, the compiler doesn't guarantee inlining, even when you specify the inline
keyword. If this is not true, please correct me.
Anyway, what happens to static variables inside this function? How many copies do I end up with?