我从开源库中读取了以下代码。令我困惑的是美元符号的用法。任何人都可以澄清代码中 $ 的含义。非常感谢您的帮助!
__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;
最佳答案
有一个 gcc 开关,-fdollars-in-identifiers
,它明确允许在标识符中使用 $。
也许他们启用它并使用 $ 作为与普通名称极不可能发生冲突的东西。
-fdollars-in-identifiers
Accept $ in identifiers. You can also explicitly prohibit use of $ with the option -fno-dollars-in-identifiers. (GNU C allows $ by default on most target systems, but there are a few exceptions.) Traditional C allowed the character $ to form part of identifiers. However, ISO C and C++ forbid $ in identifiers.
参见 the gcc documentation .希望链接保持良好。
关于c++ - C++中的$符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14595300/