don't get it with the "two-stage name lookup"
<p>I have a global macro that provides logging facilities <code>#define LOG_LOG(name,level,msg,...) {</code> I use the logging facility via another macro <code>LENTER</code> that indirectly invokes/depends on <code>LOG_LOG</code> (definitions below). The macros look like this (defined in <code>logger.h</code>):</p>

<pre><code>#define LOG_LOG(name,level,msg,...) { \
    #if defined(OS_MACOSX)\
    int tid=mach_thread_self();\
    #elif defined(OS_LINUX)\
    int tid=syscall(__NR_gettid);\
    #elif defined(OS_FREEBSD)\
    int tid=reinterpret_cast&lt;int64&gt;(pthread_self());\
    #endif\
    if (level&lt;=LOGLEVEL_WARNING){\
            fprintf(stderr,"%s %i %s:%s():%i",name, tid, __FILE__,__FUNCTION__,__LINE__);\
            fprintf(stderr," " LOG_ADDITIONAL);\
            fprintf(stderr,"--&gt; " msg, ##__VA_ARGS__);\
            fprintf(stderr,"\n");\
    }else{\
            printf("%s %i %s:%s():%i",name, tid, __FILE__,__FUNCTION__,__LINE__);\
            printf(" " LOG_ADDITIONAL);\
            printf("--&gt; " msg, ##__VA_ARGS__);\
            printf("\n");\
    }\
}

#if LOGLEVEL&gt;=LOGLEVEL_TRACE
#define LTRACE(msg,...) LOG_LOG("Trace",5,msg,##__VA_ARGS__)
#else
#define LTRACE(msg, ...) {}
#endif

#define LENTER LTRACE("entering method")
</code></pre>

<p>The client code of these macros looks like this:</p>

<pre><code>template&lt;typename T&gt;
inline void tvector&lt;T&gt;::random() {
    LENTER; 
    for (int i = 0; i &lt; size(); ++i) {
        elem(i) = (double) rand() / (double) RAND_MAX;
    }
}
</code></pre>

<p>But I still get the error:</p>

<pre><code>/Users/bravegag/code/fastcode_project/code/src/vector.h: In member function 'void tvector&lt;T&gt;::random()':
/Users/bravegag/code/fastcode_project/code/src/vector.h:223:2: error: there are no arguments to 'LOG_LOG' that depend on a template parameter, so a declaration of 'LOG_LOG' must be available [-fpermissive]
</code></pre>

<p>Which I don't get, since this is a macro available and well defined globally and has absolutely nothing to do with the template parameter of the class of the client member function <code>tvector&lt;T&gt;::random()</code>. Researching about this issue I found the link <a href="http://gcc.gnu.org/onlinedocs/gcc/Name-lookup.html" rel="nofollow">http://gcc.gnu.org/onlinedocs/gcc/Name-lookup.html</a> but this is confusing and far from the issue I have at hand.</p>

<p>This error is telling me that the definition of the <code>LOG_LOG</code> is not available ... but it is. I really don't see how this "two stage name lookup" improves the quality of the code other than creating extremely obfuscated compiler errors.</p>

<pre><code>/Users/bravegag/code/fastcode_project/build_debug$ g++ --version
g++ (MacPorts gcc46 4.6.3_2) 4.6.3
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

/Users/bravegag/code/fastcode_project/build_debug$ uname -a
Darwin Macintosh-4.local 11.4.0 Darwin Kernel Version 11.4.0: Mon Apr  9 19:32:15 PDT 2012; root:xnu-1699.26.8~1/RELEASE_X86_64 x86_64
</code></pre>
