A sensible compiler would recognize .cpp extension and treat the file as a C++ file not as a C file (even C99). You could have been fooled by the fact that some C99 features are also present in C++ (such as inline functions, // line comments, declaring variables when you need them, etc...), however the compiler would treat the C99 file as a C++ file instead (which is bad: some incompatible name decorations and variable visibility with C).
You should not rely on this behavior (changing .c into .cpp), and use the appropriate C++ compiler switch (if it exists) to ensure the C99 mode.