使用googletest测试C代码(Google C ++测试框架)

使用googletest测试C代码(Google C ++测试框架)

问题描述:

我试图用googletest测试C代码,但是当我的C头文件包含在C ++测试文件中时,我遇到一些问题,因为g ++编译器将它们作为C ++头文件处理。

I'm trying to test C code with googletest but I'm having some problems when my C header files are included in the C++ test file because the g++ compiler handle them as C++ headers.

我试图在 externC{} 中包含这些头没有成功。

I've tried to include these headers inside extern "C" {} with no success.

有没有方法g ++编译器可以处理这些标头作为C的?

Is there a way g++ compiler can handle these headers as C ones?

externC阶段名称调整。如果你使用C不共享的C功能,那么你是SOL

extern "C" only changes link stage name mangling. If you are using C features that aren't shared by C++ then you are SOL