Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8184055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:22:11+00:00 2026-06-07T01:22:11+00:00

I have a global macro that provides logging facilities #define LOG_LOG(name,level,msg,…) { I use

  • 0

I have a global macro that provides logging facilities #define LOG_LOG(name,level,msg,...) { I use the logging facility via another macro LENTER that indirectly invokes/depends on LOG_LOG (definitions below). The macros look like this (defined in logger.h):

#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<int64>(pthread_self());\
    #endif\
    if (level<=LOGLEVEL_WARNING){\
            fprintf(stderr,"%s %i %s:%s():%i",name, tid, __FILE__,__FUNCTION__,__LINE__);\
            fprintf(stderr," " LOG_ADDITIONAL);\
            fprintf(stderr,"--> " msg, ##__VA_ARGS__);\
            fprintf(stderr,"\n");\
    }else{\
            printf("%s %i %s:%s():%i",name, tid, __FILE__,__FUNCTION__,__LINE__);\
            printf(" " LOG_ADDITIONAL);\
            printf("--> " msg, ##__VA_ARGS__);\
            printf("\n");\
    }\
}

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

#define LENTER LTRACE("entering method")

The client code of these macros looks like this:

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

But I still get the error:

/Users/bravegag/code/fastcode_project/code/src/vector.h: In member function 'void tvector<T>::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]

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 tvector<T>::random(). Researching about this issue I found the link http://gcc.gnu.org/onlinedocs/gcc/Name-lookup.html but this is confusing and far from the issue I have at hand.

This error is telling me that the definition of the LOG_LOG 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.

/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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T01:22:13+00:00Added an answer on June 7, 2026 at 1:22 am

    You should rewrite your macros to something on the lines of:

    #if defined(OS_MACOSX)
    #define THREAD_ID mach_thread_self()
    #elif defined(OS_LINUX)
    #define THREAD_ID syscall(__NR_gettid)
    #elif defined(OS_FREEBSD)
    #define THREAD_ID reinterpret_cast<int64>(pthread_self())
    #endif
    
    #define LOG_LOG(name,level,msg,...) do {      \
        int64 tid = THREAD_ID;                    \
        if (level<=LOGLEVEL_WARNING) {            \
           ...                                    \
     } while(0)
    

    Note that if at least in one of your options the thread id is going to be a 64bit integer, you should use 64bit integers all along (else you will not show the correct value for BSD. Remember to pass the appropriate type to printf or make the thread number logging platform dependent. Also, all three platforms support POSIX, as far as I know, so you might want to provide an uniform implementation that will be easier to maintain.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a macro that looks like this: #define coutError if (VERBOSITY_SETTING >= VERBOSITY_ERROR)
i have a macro that i use to speed up the implementation of Factory
If i have global variable in A.dll, that depends on global variable in B.dll
I have a global variable averagel that I am trying to manipulate in a
I have a global header and footer that has a Database connection and a
I have a global variable that is an instance of my custom class. How
I have an Excel 2010 macro application that is made up of several workbook
I want to realize logging in my project. I have macro, smth like __LOG_TRACE(lg,
I am looking for a way to have a Jinja macro that calls different
I currently have a macro that uses a form in order to perform some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.