The compiler doesn't try to determine language from a .h file. The code in the .h file will be compiled as the language of the .c or .cpp file which includes it.
If the code is C, name the file .c, not .cpp. As you discovered, a lot of valid C code is not valid C++ code.