使用googletest测试C代码(Google C ++测试框架) [英] Testing C code with googletest (Google C++ Testing Framework)

查看:2092
本文介绍了使用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

这篇关于使用googletest测试C代码(Google C ++测试框架)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆