【问题标题】:Use of underscore character下划线字符的使用
【发布时间】:2014-03-06 23:19:24
【问题描述】:

我一直想知道 c 和汇编声明(以及其他任何地方)中下划线字符的功能。 像

这样的语句中的“_”是什么意思
MSVCRT!_output:
77c3f0f3 55               push    ebp
77c3f0f4 8bec             mov     ebp,esp
77c3f0f6 81ec50020000     sub     esp,0x250
77c3f0fc 33c0             xor     eax,eax
77c3f0fe 8945d8           mov     [ebp-0x28],eax
77c3f101 8945f0           mov     [ebp-0x10],eax
77c3f104 8945ec           mov     [ebp-0x14],eax
77c3f107 8b450c           mov     eax,[ebp+0xc]

或

#ifdef __unix__ /* __unix__ is usually defined by compilers targeting Unix systems */
# include <unistd.h>
#elif defined _WIN32 /* _Win32 is usually defined by compilers targeting 32 or 64 bit Windows systems */
# include <windows.h>
#endif

或

#if !(defined __LP64__ || defined __LLP64__) || defined _WIN32 && !defined _WIN64
    // we are compiling for a 32-bit system
#else
    // we are compiling for a 64-bit system
#endif

在 C 预处理器中? (这些只是我临时收集的例子=

为什么以及何时使用单下划线或双下划线? 非常感谢你的帮助! N.

【问题讨论】:

标签: assembly character preprocessor


【解决方案1】:

汇编中的下划线字符没有特殊含义。它通常用作长描述性标签中空格的替换:jumps_here_when_the_things_go_wrong:

无论如何,使用下划线作为第一个字符可能只是 C 编程的一种习惯。来自其他语言的汇编程序员不使用这样的标签。

我个人只在库中使用以下划线开头的标签来表示仅供内部使用的全局标签。

使用的下划线数量取决于从库外部使用此标签的不受欢迎程度 - 一个下划线表示“想想你做什么”,三个下划线表示“从不使用它”。

【讨论】:

  • 伙计们,我找到了我在说什么! (太奇怪了我直到现在才提出这个页面,我已经搜索了很长时间)。这是关于包括后卫的。感谢您的关注先生!
  • 只是为了确保......当你找到类似 RtlAllocateHeap (msdn.microsoft.com/en-us/library/windows/hardware/…) 的代码时,这些下划线没有任何功能,因为它们在包含警卫中......它们是只是变量名的一部分,就像组成它的任何其他字符一样,对吗?再次感谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-04-17
  • 2021-12-05
  • 1970-01-01
  • 2018-05-20
  • 2020-12-22
  • 1970-01-01
  • 2012-03-31
相关资源
最近更新 更多