constant.h:
#ifdef __cplusplus
extern "C" {
#endif
int calc_check(int);
#ifdef __cplusplus
}
#endif
The problem is that you have to declare your function as
extern "C"
when you declaring it for .cpp files because .c files generate object files where the name of functions isn't mangled (like ?calc_check@@YAHH@Z). If you don't tell
extern "C"
for .cpp files in the function declaration then the C++ sources will look for mangled names and wont find the unmangled .c symbols. With the above code your header file remains valid when included from both .c and .cpp files and tells your C++ code to look for unmangled stuff.