C ++中的$符号 [英] $ symbol in c++
问题描述
我从一个开源库中读取了以下代码.使我感到困惑的是美元符号的用法.任何人都可以在代码中阐明$的含义.非常感谢您的帮助!
I read the following code from an open source library. What confuses me is the usage of dollar sign. Can anyone please clarify the meaning of $ in the code. Your help is greatly appreciated!
__forceinline MutexActive( void ) : $lock(LOCK_IS_FREE) {}
void lock ( void );
__forceinline void unlock( void ) {
__memory_barrier(); // compiler must not schedule loads and stores around this point
$lock = LOCK_IS_FREE;
}
protected:
enum ${ LOCK_IS_FREE = 0, LOCK_IS_TAKEN = 1 };
Atomic $lock;
推荐答案
它已被用作 identifer 的一部分.
[C++11: 2.11/1]
将标识符定义为任意长的字母和数字序列".它在紧随其后的语法中定义了字母和数字",该名称仅命名数字,小写和大写罗马字母以及下划线字符,但也允许其他实现定义的字符",其中大概是一个.
[C++11: 2.11/1]
defines an identifier as "an arbitrarily long sequence of letters and digits." It defines "letters and digits" in a grammar given immediately above, which names only numeric digits, lower- and upper-case roman letters, and the underscore character explicitly, but does also allow "other implementation-defined characters", of which this is presumably one.
在这种情况下,$
除了作为标识符的一部分外没有其他特殊含义.在这种情况下,为变量的名称.在变量名称的开始中并没有特殊的意义.
In this scenario the $
has no special meaning other than as part of an identifier — in this case, the name of a variable. There is no special significance with it being at the start of the variable name.
这篇关于C ++中的$符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!