__cplusplus是什么意思??

xsy414 2004-07-22 09:08:27
还有这段代码是什么意思?我手头的资料好像没有
求大家解答

#ifdef __cplusplus
extern "C" {
#endif
…………
…………
#ifdef __cplusplus
}
#endif

小弟还有一点常识,如果__cplusplus被定义的话,
中间的定义就在 extern "C" {}的大括号里面了,这是啥作用呢
...全文
11025 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
expert2000 2004-07-22
  • 打赏
  • 举报
回复
学习,帮顶,楼主给点分我就能提高。^!^
nw61 2004-07-22
  • 打赏
  • 举报
回复
《C++ primer》
peter9606 2004-07-22
  • 打赏
  • 举报
回复
Predefined Macros
The translator predefines several macro names.

The macro __DATE__ expands to a string literal that gives the date you invoked the translator. Its format is "Mmm dd yyyy". The month name Mmm is the same as for dates generated by the library function asctime. The day part dd ranges from " 1" to "31" (a leading 0 becomes a space).

The macro __FILE__ expands to a string literal that gives the remembered filename of the current source file. You can alter the remembered filename by writing a line directive.

The macro __LINE__ expands to a decimal integer constant that gives the remembered line number within the current source file. You can alter the remembered line number by writing a line directive.

The macro __STDC__ expands to the decimal integer constant 1. The translator should provide another value (or leave the macro undefined) when you invoke it for other than a Standard C environment. For example, you can write:

#if __STDC__ != 1
#error NOT a Standard C environment
#endif
The macro __STDC_VERSION__ expands to the decimal integer constant 199409L. The translator should provide another value (or leave the macro undefined) when you invoke it for other than a Standard C environment that incorporates Amendment 1.

The macro __TIME__ expands to a string literal that gives the time you invoked the translator. Its format is "hh:mm:ss", which is the same as for times generated by the library function asctime.
mxldream 2004-07-22
  • 打赏
  • 举报
回复
只要是C++的编译器,都隐含定义了__cplusplus宏
loveisbug 2004-07-22
  • 打赏
  • 举报
回复
__cplusplus标示符用来判断程序是用c还是c++编译程序编译的。当编译c++程序时,这个标示符会被定义,编译c程序时,不会定义。
tsingien 2004-07-22
  • 打赏
  • 举报
回复
mark
geesun 2004-07-22
  • 打赏
  • 举报
回复
#ifdef __cplusplus 就是判断是不是用C++语言写的程序!这个__cplusplus 好像是C++语言固定的宏吧!
peter9606 2004-07-22
  • 打赏
  • 举报
回复
如果编译起在编译cpp文件那么__cplusplus 就会被定义 如果是一个c文件在被编译那么__STDC__就会被定义
geesun 2004-07-22
  • 打赏
  • 举报
回复
#ifdef __cplusplus 就是判断是不是用C++语言写的程序!这个__cplusplus 好像是C++语言固定的宏吧!
geesun 2004-07-22
  • 打赏
  • 举报
回复
如果整个程序是用C++写的,那么就要包含extern "C" {}
因为在C++里面写C要加上那个说明一下!
hongchi2004 2004-07-22
  • 打赏
  • 举报
回复
强烈建议你把C++ primer都看了。

69,373

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧