系统相关符号通常在哪里定义?
我正在查看 Tor 的源代码,作为 RA 项目的一部分。我试图弄清楚为什么它被自动编译为在一个系统(SuSE)上使用线程并在另一系统(Solaris)上分叉一个新进程。源代码中只有几个地方调用了 fork()
,并且它依赖于定义的各种符号(例如 ENABLE_THREADING 或 USE_PTHREADS)。我搜索了这些文件,但无法找到大多数所需符号的定义。
我并不是专门寻找这个问题的解决方案,而是寻找一个一般准则。与系统相关编译相关的符号是如何定义的以及在哪里定义的?
I'm looking at the source code for Tor as part of an RA project. I'm trying to figure out why it was automatically compiled to use threads on one system (SuSE) and forks a new process on a different system (Solaris). There are only a few places in the source code where fork()
is called, and it's dependent on various symbols (things like ENABLE_THREADING or USE_PTHREADS) being defined. I've searched the files, and have been unable to find definitions for most of the required symbols.
I'm not looking for a solution to this problem specifically, but more a general guideline. How and where are symbols relating to system dependent compiliation defined?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
老实说我不知道,但这是我的猜测。
这些是在
Makefile
中定义的宏。通常,Makefile
是由某种./configure
脚本动态生成的。请注意,在 C 和 C++ 中,常见的约定是将所有宏都设为大写字符和下划线,以便更明显地表明它们是宏。当然这只是惯例,并不是必需的。
最后,
grep
可以成为你的朋友。在源目录中尝试类似的操作:这将找到使用或定义该宏的所有文件。
I honestly don't know, but here is my guess.
These are macros which are defined in the
Makefile
. Often, theMakefile
is dynamically generated by some sort of./configure
script.Note that in C and C++, it is common convention to make all macros uppercase characters and underscores so that it is more obvious that they are macros. This is of course just convention, and not required.
In the end,
grep
can be your friend. Try something like this in the source directory:this will find all files which either use or define that macro.
这些是在构建的
configure
部分使用自动工具
。These are generated during the
configure
part of the build withautotools
.