title: Variable arguments and function overloading
body: <p>I am trying to improve SQLite error handling in an existing C++ program.  I have a custom type SQLiteException, and I want to write a macro to print the line number, file name, and error messages from SQL.</p>
  
  <p>I have the following functions defined:</p>
  
  <pre><code>LogMessage(LPCTSTR message); // Does the real work.  Appends a timestamp to the message and logs the message to disk
  
  LogMessage(LPCSTR message); // Simply converts message from ASCII to UNICODE and calls the original LogMessage(LPCTSTR message) function.
  
  LogMessage(LPCTSTR message, ...); // A new variable argument version of the function.  It uses vsprintf to format into a temporary TCHAR string, and passes that string into the first LogMessage(LPCTSTR message) function.
  </code></pre>
  
  <p>This is where I am having trouble.  The compiler is complaining about ambigious call to overloaded function.  The third function is implemented like this:</p>
  
  <pre><code>void LogMessage(LPCTSTR message, ...)
  {
  TCHAR logBuffer[513];
  va_list args;
  va_start(args, message);
  _vsntprintf(logBuffer, 512, message, args);
  va_end(args);
  LogMessage((LPCTSTR)logBuffer);
  }
  </code></pre>
  
  <p>}</p>
  
  <p>The macro I have added is written like this:</p>
  
  <pre><code>#define LOG_SQLITE_EXCEPTION(e) LogMessage(_T("%s %s %d"), CString(__FUNCTION__), CString(__FILE__), __LINE__); LogMessage(GetSQLiteErrorMessage(e));
  </code></pre>
  
  <p>How can I make the compiler call the first version of the LogMessage function in the implementation of the third version?  The compiler seems to be ignoring the '...' parameter and can't tell the difference between the first and third implementation of LogMessage.</p>