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 815121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:37:57+00:00 2026-05-15T01:37:57+00:00

I am trying to improve SQLite error handling in an existing C++ program. I

  • 0

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.

I have the following functions defined:

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.

This is where I am having trouble. The compiler is complaining about ambigious call to overloaded function. The third function is implemented like this:

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);
}

}

The macro I have added is written like this:

#define LOG_SQLITE_EXCEPTION(e) LogMessage(_T("%s %s %d"), CString(__FUNCTION__), CString(__FILE__), __LINE__); LogMessage(GetSQLiteErrorMessage(e));

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.

  • 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-05-15T01:37:58+00:00Added an answer on May 15, 2026 at 1:37 am

    Well, these are variable arguments – meaning that zero arguments is also acceptable. In that case the compiler will not be able to pick between your first and third function as their first argument is identical.

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

Sidebar

Related Questions

I trying to improve my skills using Try Catch blocks and better error handling.
I'm trying to improve an existing solr search which uses the StandardRequestHandler. I'd like
I am trying to improve my jQuery skill and I have this bit of
Im am trying to improve a ToDo app for the iPhone. I have two
I'm trying to improve the information provided in response to an error handled within
I'm trying to improve an existing implementation of document displaying component. One of the
I am trying to improve my C++ by creating a program that will take
I'm trying to improve my jquery/javascript syntax. Is there a better way to write
I am trying to improve my knowledge of OOP in PHP and have been
I am trying to improve a list collection that i have to replace values

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.