测试C code。与googletest(谷歌C ++测试框架) [英] Testing C code with googletest (Google C++ Testing Framework)

查看:153
本文介绍了测试C code。与googletest(谷歌C ++测试框架)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图来测试C code。与googletest但我有,当我的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

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

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