宏 htonl 将内部逗号解释为参数分隔符
Macro htonl interpretes inner commas as parameter separator
这是编译时返回的异常错误,仅使用某些编译器参数。
可以g++ -std=c++11 -m64 -O3 -DNDEBUG
但是随着g++ -std=c++11 -m64 -Wall -g
,会出现此问题:
宏"htonl"传递了 7 个参数,但只需要 1 个参数
法典:
const unsigned int h = htonl(hash::CompileTime<'A', 'S', 't', 'r', 'i', 'n', 'g'>::hash);
我不确定问题来自htonl
调用还是来自我的模板哈希器。
你知道怎么解决吗?
其他信息:
template<const char C0, const char C1 = ' ', const char C2 = ' ',
const char C3 = ' ', const char C4 = ' ', const char C5 = ' ',
const char C6 = ' ', const char C7 = ' ', const char C8 = ' ',
const char C9 = ' ', const char C10 = ' '>
struct CompileTime
{
//Do you think this code could help?
};
添加另一对大括号:
htonl((hash::CompileTime<'A', 'S', 't', 'r', 'i', 'n', 'g'>::hash))
一种解决方案是使用额外的括号来帮助宏:
const unsigned int h = htonl((hash::CompileTime<'A', 'S', 't', 'r', 'i', 'n', 'g'>::hash));
为了解释为什么...这篇文章会有所帮助C/C++ 宏中的逗号
这是宏内部的逗号解释问题。
相关文章:
- MSVC将仅移动结构参数解释为指针
- C++ 我应该如何解释函数参数long(*pPointer)(OtherClass *const, long)?
- C 功能具有参考参数错误的迭代器错误.寻求解释
- 左角支架解释为操作员&lt;而不是模板参数
- 转换构造函数:您如何解释C 中给定不同参数的函数
- 宏 htonl 将内部逗号解释为参数分隔符
- hpp文件中的块,这是c ++语法吗?为什么没有传入参数?有人可以解释一下,请
- C++ std::括号中的矢量参数 - 解释
- 如何解释此参数含义
- 有人能解释一下特殊的std::函数模板参数列表语法(这个奇怪的类型(Types..))吗
- 仅当参数可将某个类型的符号解释时,如何启用函数
- 重新解释一个模板非类型参数:clang c++14 vs c++1z
- 编译器未将指向字符串文本的良好指针解释为方法的参数
- C++ 将参数类型解释为构造函数
- 使用asctime_s,可以与解释参数类型c ++的人一起做
- 解释此并发中的"="符号参数::任务调用
- 用于解释参数的方法
- 像"T"这样的模板参数是否总是被解释为每个值?
- C++node.js插件-Init()中参数的解释
- 有人能解释参数void(*pfn)(void*)吗