帮助__cplusplus [英] Help with __cplusplus

查看:46
本文介绍了帮助__cplusplus的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Netlanders,我开始学习''C''语言

并阅读一些代码我找到了这段代码:


# ifdef __cplusplus

externC {

#endif


是否有人可以向我解释这段代码,因为

我看到这个__ cplusplus ;和外部C和 {"看看C和C ++之间的区别是一种

标准,但我不确定

我想要更多信息......


如果你知道这些东西或有关阅读的信息请

让我知道。

Hello Netlanders, I''m starting to learn the ''C'' language
and reading some code I found this code:

#ifdef __cplusplus
extern "C" {
#endif

Is there someone who could explain me about this code, because
I see that this "__cplusplus" and "extern "C" {" is a kind of
standard to see the difference between C and C++, but I''m not sure
and I want more Information ...

If you know about this stuff or about a reading to consult please
let me know it.

推荐答案

Arturo写道:
Arturo writes:
我开始学习''C''语言
并阅读一些代码我找到了这段代码:

#ifdef __cplusplus
externC {
#endif

是否有人可以向我解释这段代码,因为
我看到这个__ cplusplus和外部C和 {"是一种看待C和C ++之间差异的标准,但我不确定
我想要更多信息...

如果你知道这个请给我一些阅读材料。
让我知道。
I''m starting to learn the ''C'' language
and reading some code I found this code:

#ifdef __cplusplus
extern "C" {
#endif

Is there someone who could explain me about this code, because
I see that this "__cplusplus" and "extern "C" {" is a kind of
standard to see the difference between C and C++, but I''m not sure
and I want more Information ...

If you know about this stuff or about a reading to consult please
let me know it.




看起来您遇到了库函数的标题和

供应编译器的供应商对C ++编译器使用相同的库。

这是常态,如今。 __cplusplus意味着*你的*编译器

(它不能代表C标准中的任何内容,因为时间似乎仅在前向方向上流入
而在C ++之前是C )。语法externC。 {是一种方式

来击败名称错误,C ++有一个属性而C没有。


我可能错了但我的猜测是你正在服用

学习的错误方法;当你遇到

时,试图吸收并让一切都有意义。这些新闻组中的很多人都含蓄地提倡这一点,但是我个人,毕竟我的运气非常糟糕,学习*任何东西*

方式。先熟悉编写简单的程序,然后再回去,

填补你知识的漏洞。有些人称之为螺旋式或

螺旋式方法。在你最终吸收之前可能需要多次重访

all - 在C ++的情况下你可能会先死掉。


查看标题不是新手学习任何东西的好方法

除了计算机编程是一项复杂的业务。



It looks like you have encountered the header of a library function and the
vendor that supplies the compiler uses the same library for a C++ compiler.
This is the norm, nowadays. __cplusplus means something to *your* compiler
(it can''t mean anything in the C standard because time only seems to flow in
the forward direction and C preceded C++). The syntax extern"C" { is a way
to defeat name mangling, a property that C++ has and C does not.

I could be wrong but my guess is you are taking the wrong approach to
learning; trying to absorb and have everything make sense as you encounter
it. A great many people on these newsgroups implicitly advocate that but I,
personally, have had very poor luck my entire life learning *anything* that
way. Get fairly fluent in writing simple programs first, then go back and
fill in the holes in your knowledge. What some people call a spiral or
helical approach. It may take several revisits before you finally absorb it
all - in the case of C++ you may very well die first.

Looking at headers is not a good way for a novice to learn much of anything
except that computer programming is a complex business.


例如****** @ yahoo.com.mx (Arturo)写道:
eg******@yahoo.com.mx (Arturo) wrote:
Hello Netlanders,I''我开始学习'''C语言
并阅读一些代码我发现这段代码:

#ifdef __cplusplus
extern" C" {
#endif

是否有人可以向我解释这段代码,因为
我看到这个__ cplusplus和外部C和 {"是一种看C和C ++之间区别的标准,但我不确定
我想要更多信息...


[火焰屏蔽:警告,部分OT]


__cplusplus是一个宏,C实现*不允许在标准符合模式下定义
。它通常由

C ++编译器定义。外部C表示外部C。 part告诉C ++编译器,

以下代码需要C调用约定。 (请注意:进一步

关于C ++的问题应该转到comp.lang.c ++以避免

烦恼。)

如果你知道的话这个东西或关于阅读请咨询
让我知道。
Hello Netlanders, I''m starting to learn the ''C'' language
and reading some code I found this code:

#ifdef __cplusplus
extern "C" {
#endif

Is there someone who could explain me about this code, because
I see that this "__cplusplus" and "extern "C" {" is a kind of
standard to see the difference between C and C++, but I''m not sure
and I want more Information ...
[flame-shield: warning, partially OT]

__cplusplus is a macro that a C implementation is *not* allowed to
define in standard conforming mode. It''s conventionally defined by
C++ compilers. The extern "C" part tells a C++ compiler, that the
following code requires C calling conventions. (Please note: further
questions about C++ should be directed to comp.lang.c++ to avoid
irritations.)
If you know about this stuff or about a reading to consult please
let me know it.




你肯定想阅读_C编程语言_由Kernighan

和Ritchie,第二版(K& R2),伴随着comp.lang.c-FAQ

(签名链接)。顺便说一句,常见问题解答在第18.10节提供了一些更好的书

建议。


祝你好运!


问候

-

Irrwahn Grausewitz(ir*******@freenet.de)

欢迎来到clc: http://www.ungerhu.com/jxh/clc.welcome.txt

clc faq-list: http ://www.faqs.org/faqs/C-faq/faq/

clc OT指南: http://benpfaff.org/writings/clc/off-topic.html



You definitely want to read _The C Programming Language_ by Kernighan
and Ritchie, second edition (K&R2), accompanied by the comp.lang.c-FAQ
(link in signature). BTW, the FAQ provides some more good book
recommendations in section 18.10.

Good luck!

Regards
--
Irrwahn Grausewitz (ir*******@freenet.de)
welcome to clc: http://www.ungerhu.com/jxh/clc.welcome.txt
clc faq-list : http://www.faqs.org/faqs/C-faq/faq/
clc OT guide : http://benpfaff.org/writings/clc/off-topic.html


2004年6月9日星期三,Arturo写道:
On Wed, 9 Jun 2004, Arturo wrote:
Hello Netlanders,我开始学习''C''语言
并阅读一些代码我找到了这段代码:

#ifdef __cplusplus
externC {
#endif

是否有人可以向我解释这段代码,因为
我看到这个__ cplusplus和外部C和 {"是一种看待C和C ++之间差异的标准,但我不确定
我想要更多信息...

如果你知道这个请参考或者阅读请参阅
让我知道。
Hello Netlanders, I''m starting to learn the ''C'' language
and reading some code I found this code:

#ifdef __cplusplus
extern "C" {
#endif

Is there someone who could explain me about this code, because
I see that this "__cplusplus" and "extern "C" {" is a kind of
standard to see the difference between C and C++, but I''m not sure
and I want more Information ...

If you know about this stuff or about a reading to consult please
let me know it.




这是C ++的一个功能。您正在查看的代码是为作为C或C ++编译器的

编译器而设计的。如果为C

设置开关,则#ifdef为false并使用extern。如果设置开关为
C ++,则#ifdef为true,并且它根据C ++的要求使用extern。如果你对b $ b感兴趣,请向comp.lang.c ++中的人询问

''extern" C"''是关于或查看一个关于C ++的书。


-

发送电子邮件至:darrell at cs dot toronto dot edu

Don''发送电子邮件至 vi ************ @ whitehouse.gov


这篇关于帮助__cplusplus的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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