本文介绍了#ifdef __cplusplus的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 限时删除!! 我在一些代码中看到: #ifdef __cplusplus externC { #endif 这是什么意思? 谢谢 - __mattia__ 解决方案 mattia说: 我已经看到了一些代码: #ifdef __cplusplus externC { #endif 这是什么意思? 这意味着某人还没有决定他们写的是哪种语言。 最好避免。 - Richard Heathfield< http://www.cpax.org.uk> 电子邮件:-http:// www。 + rjh @ 谷歌用户:< http://www.cpax.org.uk/prg/writings/googly.php> Usenet是一个奇怪的放置" - 1999年7月29日dmr 文章< 47 *********************** @ reader4 .news.tin.it>, mattia< ge **** @ gmail.comwrote: >我''我们在一些代码中看到: > #ifdef __cplusplus extern" C" { #endif 是什么意思? 这与C ++有关。 AC编译器不会定义__cplusplus ,因此C编译器会将这些行编译为虚无。 此表单检测代码是否正在编译C ++ 编译器,如果是,则包含externC编译器。围绕代码块的{}。 externC的含义。 {}特定于C ++,并且在C ++中意味着 所包含的代码块将使用C调用序列而不是C ++调用序列来编译其函数。 C调用序列与C ++ 调用序列之间最重要的区别是C ++调用序列(通常)具有名为b $ ba隐藏参数的名称。 ;这"指的是操作的对象是;在C ++中使用这种语法告诉C ++不要将隐藏参数放入 中,从而使定义的函数适合于从C调用 (或者,交替地,-declaring- functions因为 外部函数需要C风格的参数来调用。) - "当我们都认为相似时,没有人是非常想。 - Walter Lippmann 4月9日,9:26 * am,mattia< ger ... @ gmail.comwrote: 我在某些代码中看到: #ifdef __cplusplus * externC * { #endif 这是什么意思? 这意味着令牌externC如果定义了__cplusplus预处理器符号,则是 翻译单元的一部分。 某处更远,应该有匹配的 #ifdef __cplusplus } #endif 关闭大括号。 I''ve see in some code:#ifdef __cplusplusextern "C"{#endifwhat does it mean?Thanks--__mattia__ 解决方案 mattia said:I''ve see in some code:#ifdef __cplusplus extern "C" {#endifwhat does it mean?It means that someone hasn''t decided which language they''re writing in.Best avoided.--Richard Heathfield <http://www.cpax.org.uk>Email: -http://www. +rjh@Google users: <http://www.cpax.org.uk/prg/writings/googly.php>"Usenet is a strange place" - dmr 29 July 1999In article <47***********************@reader4.news.tin.it>,mattia <ge****@gmail.comwrote:>I''ve see in some code:>#ifdef __cplusplusextern "C"{#endifwhat does it mean?This has to do with C++. A C compiler will not defne __cplusplusand so a C compiler will compile those lines to nothingness.This form detects that whether the code is being compiled with a C++compiler, and if it is, wraps extern "C" { } around the block of code.The meaning of extern "C" { } is specific to C++, and in C++ meansthat the enclosed block of code is to have its functions compiledwith C calling sequences rather than C++ calling sequences. Thesingle most important difference between C calling sequences and C++calling sequences is that C++ calling sequences (usually) havea hidden parameter named "this" that refers to the object beingoperated upon; using this syntax in C++ tells C++ to not put inthat hidden parameter, thus leaving the functions defined suitable forcalling from C (or, alternately, -declaring- functions as beingexternal functions that need C-style parameters to call.)--"When we all think alike no one is thinking very much."-- Walter LippmannOn Apr 9, 9:26*am, mattia <[email protected]:I''ve see in some code:#ifdef __cplusplus*extern "C"*{#endifwhat does it mean?It means that the tokens extern "C" { are part of thetranslation unit if the __cplusplus preprocessor symbol is defined.Somewhere farther down, there should be a matching#ifdef __cplusplus}#endifto close the brace. 这篇关于#ifdef __cplusplus的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 1403页,肝出来的..
09-07 16:58