2

This is a unusual error returned at compile time, only with some compiler parameters.

OK with g++ -std=c++11 -m64 -O3 -DNDEBUG

But with g++ -std=c++11 -m64 -Wall -g, this problem occurs:

macro "htonl" passed 7 arguments, but takes just 1

Code:

const unsigned int h = htonl(hash::CompileTime<'A', 'S', 't', 'r', 'i', 'n', 'g'>::hash);

I'm not sure if the problem comes from the call of htonlor if it comes from my templated hasher.

Do you know how to solve that?

Other infos:

template<const char C0,         const char C1 =  '\0', const char C2 =  '\0', 
         const char C3  = '\0', const char C4 =  '\0', const char C5 =  '\0', 
         const char C6  = '\0', const char C7 =  '\0', const char C8 =  '\0', 
         const char C9  = '\0', const char C10 = '\0'>
struct CompileTime
{
    //Do you think this code could help?
};
P.W
  • 26,289
  • 6
  • 39
  • 76
Sandburg
  • 757
  • 15
  • 28

2 Answers2

6

Add another pair of braces:

htonl((hash::CompileTime<'A', 'S', 't', 'r', 'i', 'n', 'g'>::hash))

Abyx
  • 12,345
  • 5
  • 44
  • 76
1

One solution is to help the macro with additional parenthesis:

const unsigned int h = htonl((hash::CompileTime<'A', 'S', 't', 'r', 'i', 'n', 'g'>::hash));

To explain why... this post will help Comma in C/C++ macro

It's a question of comma interpretation inside macros.

Sandburg
  • 757
  • 15
  • 28