- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
我在 the libmagic
code 中找到了这些行.它们是什么意思?
#ifdef __GNUC__
__attribute__((unused))
#endif
__GNUC__
是什么意思?
好像检查whether GCC is installed .
什么是__attribute__((unused))
?
这里有一个代码片段,但没有解释:How do I best silence a warning about unused variables?
__GNUC__
和_MSC_VER
有什么区别?_MSC_VER
上面有一些解释,但到底是什么?
How to Detect if I'm Compiling Code with a particular Visual Studio version?
最后一个问题:
如何执行相同的 #ifdef
来检查哪个编译器正在编译我的代码?
最佳答案
在编译器中定义宏来确定它们是什么编译器、版本是什么是很常见的……可移植的 C++ 代码可以使用它们来确定它是否可以使用特定的功能。
What does
__GNUC__
mean?
这表明我是一个 GNU 编译器,你可以使用 GNU 扩展。 [1]
What is
__attribute__((unused))
?
附加到变量的此属性意味着该变量可能未被使用。 GCC 不会为此变量生成未使用的变量警告。 [2]
What is the difference between
__GNUC__
and_MSC_VER
?
它们是两个不相关的宏。第一个说我是 GNU 编译器,第二个说 MS 编译器的版本号。但是,MS 编译器不应该支持 GNU 扩展。
How can I do the same
#ifdef
to check whether OS is compiling my python code using GNU and MS visual studios?
#if (defined(__GNU__) && defined(_MSC_VER))
// ...
#endif
但是,没有机会同时具备这些条件!
关于c - 这个#ifdef __GNUC__ 是关于什么的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19908922/
这个问题可能很奇怪,我目前正在研究一些旧代码(不是我写的)。我实际上不是 C 程序员,但我想了解这部分代码实际上应该做什么。幸运的是,奇怪的部分并不太长(配置的一部分): int main () {
这个问题可能很奇怪,我目前正在研究一些旧代码(不是我写的)。我实际上不是 C 程序员,但我想了解这部分代码实际上应该做什么。幸运的是,奇怪的部分并不太长(配置的一部分): int main () {
我在 the libmagic code 中找到了这些行.它们是什么意思? #ifdef __GNUC__ __attribute__((unused)) #endif __GNUC__ 是什么意思?
我正在研究 stm 的 STM32l151rct6a,我偶然发现了这些 MACRO 定义 __CC_ARM, __ICCARM__, __GNUC__, __TASKING__ 有谁知道他们的意思吗?
我正在尝试编译 android-kernel-goldfish-2-6-29 但是当我使用 make -j2 编译它时,我得到了这个错误: include/linux/compiler-gcc.h:8
这将是一个非常奇怪的问题,但是是否可以在 visual studio 2010/2012 设置中取消定义 _WIN32 并定义 __GNUC__ 而不触及任何源代码? 我在“C/C++ -> 预处理器
这将是一个非常奇怪的问题,但是是否可以在 visual studio 2010/2012 设置中取消定义 _WIN32 并定义 __GNUC__ 而不触及任何源代码? 我在“C/C++ -> 预处理器
我是一名优秀的程序员,十分优秀!