Marco A.
Marco A.

Reputation: 43662

Includes and namespaces

I have a file named header1.h with the following code

#include "string.h"

namespace custom1
{

    #define MYMACRO(f, z) strrchr(f, z)
}

but now I'm getting compilation errors with gcc like

OtherHeader.h error: there are no arguments to ‘strrchr’ that depend on a template parameter, so a declaration of ‘strrchr’ must be available [-fpermissive]

Why isn't the "string.h" inclusion visible? Can another file do this

namespace custom1
{
  is MYMACRO visibile here?
}

?

Why am I getting the depend error?

Upvotes: 0

Views: 76

Answers (2)

frow
frow

Reputation: 874

The signature of the strrchr function is

char *strrchr(const char *s, int c);

so I think you are just missing an argument.

Upvotes: 0

user2249683
user2249683

Reputation:

Preprocessor macros have no notion of namespaces, they do 'global text processing', always.

Upvotes: 1

Related Questions