Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ Why does 'note: see reference to class template instantiation being compiled' [duplicate]

in an .hpp file, I have a template function which is member of class.

class BLog
{
  public:
    enum { LOG_ERROR, LOG_WARN, LOG_STATUS, LOG_INFO, LOG_NOTICE, LOG_DEBUG };

    template <typename... Args>
    void appLog(int prio, const char *fmt, Args const &... args);
    template <typename... Args>
    void appLogError(const char *fmt, Args const &... args) { this->appLog(LOG_ERROR, fmt, args...);  } 
}

When calling this,

int main() 
{
    BLog myLog();

    myLog.appLog(BLog::LOG_ERROR, "%s message", "Test");
}

I am getting the warning as

note: see reference to function template instantiation 'void myLog::appLog(int,const char *,const char (&)[5])' being compiled

Can't figure out the proper syntax to pass arguments...

Hope someone can help.Thanks in advance.

Rem: With the proposed answer, using Visual Studio, I always have the warning with the W4 flag.

like image 745
LeMoussel Avatar asked Aug 31 '25 18:08

LeMoussel


1 Answers

  1. BLog myLog(); is a function declaration. Use BLog myLog{};.

  2. myLog::LOG_ERROR should be BLog::LOG_ERROR.

like image 117
Evg Avatar answered Sep 02 '25 07:09

Evg