本文介绍了在各种编译器中如何定义__cplusplus指令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我的编译器将其扩展为199711L。这意味着什么?我读到__cplusplus> 199711L表示C ++ 11。

My compiler expands it to 199711L. What does that mean? I read that __cplusplus > 199711L signifies C++11. What are the possible expansions of this macro and what does it signify?

推荐答案

199711L代表Year = 1997,Month = 11 (即1997年11月)-委员会批准该标准的日期,ISO的其余部分于1998年初批准。

The 199711L stands for Year=1997, Month = 11 (i.e., November of 1997) -- the date when the committee approved the standard that the rest of the ISO approved in early 1998.

对于2003年标准,有

For the 2003 standard, there were few enough changes that the committee (apparently) decided to leave that value unchanged.

对于2011年的标准,必须将其定义为201103L(再次,year = 2011)。 ,月= 03)再次表示该委员会批准了2011年3月最终确定的标准。

For the 2011 standard, it's required to be defined as 201103L, (again, year=2011, month = 03) again meaning that the committee approved the standard as finalized in March of 2011.

对于2014年标准,必须将其定义为201402L,与上述方法(2014年2月)相同。

For the 2014 standard, it's required to be defined as 201402L, interpreted the same way as above (February 2014).

对于2017年标准,必须将其定义为201703L(2017年3月)。

For the 2017 standard, it's required to be defined as 201703L (March 2017).

在批准原始标准之前,很多编译器通常将其定义为 0 (或者只是一个空的定义像 #define __cplusplus 之类的符号表示不符合。当被问到最严格的一致性时,许多人将其定义为 1

Before the original standard was approved, quite a few compilers normally defined it to 0 (or just an empty definition like #define __cplusplus) to signify "not-conforming". When asked for their strictest conformance, many defined it to 1.

我差点忘了提,但是还有一个关于古代编译器的花絮:最早的cfront版本(可能还有其他一些版本)定义了 c_plusplus 而不是 __ cplusplus 。我不记得它被定义为任何有意义的值了。

I almost forgot to mention, but one more tidbit about ancient compilers: a few of the earliest versions of cfront (and probably a few others copying it) defined c_plusplus instead of __cplusplus. I don't recall it's being defined to any meaningful value though.

这篇关于在各种编译器中如何定义__cplusplus指令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 11:07