草庐IT

variadic-macros

全部标签

C++ 断言 : the precedence of the expression in an assert macro

在C++中:assert(std::is_same::value);//doesnotcompileassert((std::is_same::value));//compiles谁能解释一下原因? 最佳答案 assert是一个预处理器宏。预处理器宏是愚蠢的;他们不懂模板。预处理器在括号内看到10个标记:assert(std::is_same::value);它以逗号分隔。它不知道这是错误的分割位置,因为它不明白std::is_same和int>::value不是有效的C++表达式。预处理器足够聪明,不会在多个参数之间分解内部括号对

c++ - 必须使用 MACRO 的极少数情况

Debuggingmacroscantakealotoftime.Wearemuchbetteroffavoidingthemexceptintheveryrarecaseswhenneitherconstants,functionsnortemplatescandowhatwewant.什么是罕见的情况? 最佳答案 如果您想要实际的文本替换,那么您可以使用宏。看看Boost.Preprocessor,这是在C++03中模拟可变参数模板而无需过多重复的好方法。换句话说,如果您想操作程序代码本身,请使用宏。另一个有用的应用是asser

c++ - __STDC_LIMIT_MACROS 和 __STDC_CONSTANT_MACROS 是什么意思?

我在系统的标准C++库以及我正在使用的库中的一些头文件中看到了这一点。这两个定义的语义是什么?除了源本身之外,还有像这样的#defines的好的引用吗? 最佳答案 __STDC_LIMIT_MACROS和__STDC_CONSTANT_MACROS是一种解决方法,允许C++程序使用C99标准中指定但不在C++标准。UINT8_MAX、INT64_MIN和INT32_C()等宏可能已经在C++应用程序中以其他方式定义。为了让用户决定是否要像C99那样定义宏,许多实现要求在stdint.h之前定义__STDC_LIMIT_MACROS和

c++ - VS 2015编译cocos2d-x 3.3报错 "fatal error C1189: #error: Macro definition of snprintf conflicts with Standard Library function declaration"

当我使用visualstudio2015编译cocos2d-x(3.3版)时,出现错误,说:fatalerrorC1189:#error:MacrodefinitionofsnprintfconflictswithStandardLibraryfunctiondeclaration(编译源文件..\base\s3tc.cpp)源码为:#ifdefsnprintf#errorMacrodefinitionofsnprintfconflictswithStandardLibraryfunctiondeclaration#endif谁能告诉我怎么了? 最佳答案

c++ - 警告 C4003 : not enough actual parameters for macro 'max' - Visual Studio 2010 C++

在VisualStudio2010SP1上编译openFrameworks007项目时出现以下警告:d:\pedro\development\videoflow\openframeworks\libs\openframeworks\types\ofcolor.h(127):warningC4003:notenoughactualparametersformacro'max'd:\pedro\development\videoflow\openframeworks\libs\openframeworks\types\ofcolor.h(128):warningC4003:notenoug

c++ - PCH 警告 : header stop cannot be in a macro or #if block - Visual C++ 2010 Express SP1

这是从网站粘贴的,该网站可能正在运行。我做了一些谷歌搜索,发现我现在遇到的问题是我今天下载的VisualC++2010SP1的结果,现在给我这个错误:PCH警告:标题停止不能在宏或#ifblock中。希望有人能帮我解决这个问题!#ifndefAPP_STATE_H#defineAPP_STATE_H#include"Framework.h"classAppState;//thislineisgivingmetheerror//definetwoclasses#endif框架.h:#ifndefOGRE_FRAMEWORK_H#defineOGRE_FRAMEWORK_H#include

ruby - 如何使 Yard `@macro` 应用于多个文件

如果我在一个文件中有以下内容:moduleSomethingclassResource#Definesanewproperty#@param[String]namethepropertyname#@param[Class]typetheproperty'stype#@macro[attach]property#@return[$2]the$1propertydefself.property(name,type)endendclassPost定义的方法property得到了正确的记录。但是,如果我在单独的文件中有这些定义,则无法正确生成文档,例如以下情况:file0.rb:require

c++ - 可变参数宏是非标准的吗?

对于调试构建,我通常使用Clang,因为它可以更好地格式化警告和错误,并且更容易跟踪和修复它们。但最近在添加了带有可变参数的宏后,Clang告诉我以下内容(来自一个虚拟项目):main.cpp:5:20:warning:namedvariadicmacrosareaGNUextension[-Wvariadic-macros]#definestuff3(args...)stuff_i(args)我知道macroname(args...)在各种编译器中都能很好地编译,包括Visualstudio、Sunstudio,当然还有GCC。但是为了确保clang是正确的,我尝试了另外两种扩展可变

c++ - 可变参数宏是非标准的吗?

对于调试构建,我通常使用Clang,因为它可以更好地格式化警告和错误,并且更容易跟踪和修复它们。但最近在添加了带有可变参数的宏后,Clang告诉我以下内容(来自一个虚拟项目):main.cpp:5:20:warning:namedvariadicmacrosareaGNUextension[-Wvariadic-macros]#definestuff3(args...)stuff_i(args)我知道macroname(args...)在各种编译器中都能很好地编译,包括Visualstudio、Sunstudio,当然还有GCC。但是为了确保clang是正确的,我尝试了另外两种扩展可变

c++ - 错误 : macro names must be identifiers using #ifdef 0

我有一个用C++编写的应用程序的源代码,我只想用以下方式评论一些东西:#ifdef0...#endif我得到了这个错误error:macronamesmustbeidentifiers为什么会这样? 最佳答案 #ifdef指令用于检查是否定义了预处理器符号。标准(C116.4.2标识符)规定标识符不得以数字开头:identifier:identifier-nondigitidentifieridentifier-nondigitidentifierdigitidentifier-nondigit:nondigituniversal-