cpt.h
#ifndef _HEADER_CPT_
#define _HEADER_CPT_
#ifdef __cplusplus
extern "C"{
#endif
void pt();
#ifdef __cplusplus
}
#endif
#endif // _HEADER_CPT_
cpt.cpp
#include "cpt.h"
#include <iostream>
void pt()
{
std::cout << "pt print" << std::endl;
}
test.c
#include "cpt.h"
int main() {
pt();
}
编译器:
g++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
编译指令:
g++ cpt.cpp test.c -o run
输出:pt print
Reference
https://www.cnblogs.com/skynet/archive/2010/07/10/1774964.html