Can I write my own .c and .h files and use them with .pde main project?

In order to support overloading, C++ performs an operation called name mangling. The result is that a function's real name is defined by the user-supplied function name, and the types of all the arguments.

C doesn't support overloading, so it doesn't play well when the C++ compiler has mangled the names.

The C++ compiler CAN compile C code without name mangling, so that the c extension can be used, if some compiler directives are added to the header file.

#ifdef __cplusplus
extern "C" {
#endif

// The C function declarations go here

#ifdef __cplusplus
}
#endif

The __cplusplus symbol is defined by the C++ preprocessor, but not by the C preprocessor, so, when the C++ compiler runs, it sees the extern "C" wrapper, but the C compiler does not.

The extern "C" directive tells the C++ compiler not to perform name mangling, since the functions in the block are to be called by C code, too.

Since the code in the .c file is compiled by the C compiler, which does not perform name mangling, the un-mangled names are what the C++ compiler needs to add to the symbol table for the linker to use.

Without the extern "C" directive, the mangled names are added to the symbol table by the C++ compiler, but not by the C compiler, so the linker can't find the function since the name in the symbol table (of the compiled function) doesn't match the name of the called function.