本文介绍了如何在c中使用关键字extern?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

任何人都可以告诉我keyworkdextern的使用情况。在c?并且

c& cplusplus?

$ C $ b在C99Rationalv5.10.pdf中列出了4个案例。而第一个

常见案例会招致vc编译器抱怨。

解决方案




至于Visual C ++可能会抱怨什么,它可能会产生影响

是否将它用作C或C ++编译器,因为它处理两种语言。


您引用的文档不一定一个很多人

有。


即使对于那些像我一样的人,你的参考也太模糊了。

该文件超过200页,extern一词多次出现

。我花了很短的时间查看PDF和印刷版本的b $ b版本,并没有找到你所指的部分。


再次发布和包括文档中的特定部分编号。

也就是说,如果您确实正在编译C代码而不是C ++。对于

的读者来说,他们没有理由的副本,复制并粘贴你要引用的代码示例,并复制并粘贴编译器

或链接器错误消息。


-

Jack Klein

主页:


$常见问题b $ b comp.lang.c

comp.lang.c ++

alt.comp.lang.learn .c-c ++




extern关键字指定声明的标识符具有
外部链接。这允许在一个翻译单元(基本上,源文件及其包含的所有内容)中定义对象或功能,并通过其他翻译单元中的代码按名称引用。



C ++在这里是偏离主题的,新闻:comp.lang.c ++就在大厅的右边。



至于Visual C ++可能会抱怨什么,它可能会有所作为
你是否是使用它作为C或C ++编译器,因为它处理两种语言。

您引用的文档不一定是许多人所拥有的文件。
文件超过200页,extern这个词多次出现。我花了很短的时间查看我的PDF和打印的版本,但没有找到你所指的部分。

再次发布并包含文档中的特定部分编号。
也就是说,如果您确实正在编译C代码而不是C ++。对于那些没有理由副本的读者,请复制并粘贴您所指的代码示例,并复制并粘贴编译器
或链接器错误消息。



hallo,

第6.2.2节中的
标识符的链接

有一个表列出了4个案例还包括详细信息。


关键字extern的区别是什么?出现以及何时出现?

例如,

++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++

extern int var1; | int var1;

_______________________________

extern void func(); | void func();


在ac文件中。




extern关键字指定声明的标识符具有
外部链接。这允许在一个翻译单元(基本上,源文件及其包含的所有内容)中定义对象或功能,并通过其他翻译单元中的代码按名称引用。



C ++在这里是偏离主题的,新闻:comp.lang.c ++就在大厅的右边。



至于Visual C ++可能会抱怨什么,它可能会有所作为
你是否是使用它作为C或C ++编译器,因为它处理两种语言。

您引用的文档不一定是许多人所拥有的文件。
文件超过200页,extern这个词多次出现。我花了很短的时间查看我的PDF和打印的版本,但没有找到你所指的部分。

再次发布并包含文档中的特定部分编号。
也就是说,如果您确实正在编译C代码而不是C ++。对于那些没有理由副本的读者,请复制并粘贴您所指的代码示例,并复制并粘贴编译器
或链接器错误消息。




hallo,

第6.2.2节中的
标识符的链接

有一张表列出的4个案例还包括详细信息。


关键字extern的区别是什么?出现以及何时出现?

例如,

++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | int var1;

__________________________________________________ ___________

extern int var1 = 0x0bad | int var1 = 0x0bad

__________________________________________________ ___________

extern void func(); | void func();

++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ BR />

hi all ,
anyone could tell me the useage of the keyworkd "extern" in c? and
the difference between c & cplusplus?

in the C99Rationalv5.10.pdf it lists 4 cases. while the first
common cases will incur the vc compiler to complain.

解决方案



As to what Visual C++ might complain about, it might make a difference
whether you are using it as a C or C++ compiler, as it handles both
languages.

The document you reference is not necessarily one that many people
have.

Even for those who do, like I do, your reference is far too vague.
The document is well over 200 pages, and the word ''extern'' appears
many times. I spent a brief time looking in both the PDF and printed
versions I have, and did not find the section you are referring to.

Post again and include the specific section number from the document.
That is, if you are indeed compiling C code and not C++. And for
readers here who do not have a copy of the rationale, copy and paste
the code sample you are referring to, and copy and paste the compiler
or linker error messages as well.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html




The extern keyword specifies that the identifier being declared has
external linkage. This allows an object or function to be defined in
one translation unit (basically, source file and everything it
includes) and referred to by name from code in other translation
units.



C++ is off-topic here, news:comp.lang.c++ is down the hall to the
right.



As to what Visual C++ might complain about, it might make a difference
whether you are using it as a C or C++ compiler, as it handles both
languages.

The document you reference is not necessarily one that many people
have.

Even for those who do, like I do, your reference is far too vague.
The document is well over 200 pages, and the word ''extern'' appears
many times. I spent a brief time looking in both the PDF and printed
versions I have, and did not find the section you are referring to.

Post again and include the specific section number from the document.
That is, if you are indeed compiling C code and not C++. And for
readers here who do not have a copy of the rationale, copy and paste
the code sample you are referring to, and copy and paste the compiler
or linker error messages as well.


hallo,

in section 6.2.2 Linkages of identifiers
there is a table listed the 4 cases also includes detail info.

what''s the difference when the keyword "extern" appears and when it doest appear?
for instance,
+++++++++++++++++++++++++++++++
extern int var1; | int var1;
_______________________________
extern void func(); | void func();

in a c file.




The extern keyword specifies that the identifier being declared has
external linkage. This allows an object or function to be defined in
one translation unit (basically, source file and everything it
includes) and referred to by name from code in other translation
units.



C++ is off-topic here, news:comp.lang.c++ is down the hall to the
right.



As to what Visual C++ might complain about, it might make a difference
whether you are using it as a C or C++ compiler, as it handles both
languages.

The document you reference is not necessarily one that many people
have.

Even for those who do, like I do, your reference is far too vague.
The document is well over 200 pages, and the word ''extern'' appears
many times. I spent a brief time looking in both the PDF and printed
versions I have, and did not find the section you are referring to.

Post again and include the specific section number from the document.
That is, if you are indeed compiling C code and not C++. And for
readers here who do not have a copy of the rationale, copy and paste
the code sample you are referring to, and copy and paste the compiler
or linker error messages as well.



hallo,

in section 6.2.2 Linkages of identifiers
there is a table listed the 4 cases also includes detail info.

what''s the difference when the keyword "extern" appears and when it doest appear?
for instance,
++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++
extern int var1; | int var1;
__________________________________________________ ___________
extern int var1 = 0x0bad | int var1 = 0x0bad
__________________________________________________ ___________
extern void func(); | void func();
++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++

in a c file.


这篇关于如何在c中使用关键字extern?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 14:35