C ++"如果我使用extern&QUOT会发生什么;与C工具链? [英] What happens if I use extern "C++" with a C toolchain?

查看:84
本文介绍了C ++"如果我使用extern&QUOT会发生什么;与C工具链?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题主要是关于一个C ++工具链理解C和C ++,事实如此,如果我喂一些code与的externC一个C ++工具链我相信它能够理解做什么用的;但如果我喂code与的externC ++来一个C工具链?

My question is mainly about the fact that a C++ toolchain "understands" both C and C++, so if I feed some code with an extern "C" to a c++ toolchain I assume it can understand what to do with that; but what if I feed code with extern "C++" to a C toolchain ?

什么是预期的行为?

推荐答案

如果编译器也明白C ++,它可能会接受它。如果它是一个纯粹的C编译器将对象(就像它会在的externC作为语法不是有效的C - 这就是为什么它通常附带的#ifdef __cplusplus 或类似)

If the compiler ALSO understands C++, it may accept it. If it's a pure C compiler it will object (just like it will on extern "C" as that syntax is not valid C - this is why it's typically enclosed with #ifdef __cplusplus or some such)

这篇关于C ++"如果我使用extern&QUOT会发生什么;与C工具链?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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