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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:49:35+00:00 2026-05-12T10:49:35+00:00

With gcc versions before 3.3 and with the MS compiler I use the following

  • 0

With gcc versions before 3.3 and with the MS compiler I use the following macro:

DEBUG_WARNING(...) printf(">WARNING: "__FUNCTION__"() " __VA_ARGS__);

Use:

DEBUG_WARNING("someFunction returned %d", ret); 

Output:

>WARNING: Class::FunctionName() someFunction returned -1

Its extremely handy when we have lots of systems, all sending output. Its a single line macro, that allows us to filter the output accordingly. Small code, big use, happy me.

As the __FUNCTION__ (and __func__ in C++) definition has changed (to make it standards compliant I believe) it has also made that macro unworkable.

I’ve got it working using a function that builds the string by hand, but I like my macro.

Am I missing an easy way to get this simple one line macro to still work under Gcc 3.3?

: D

  • 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-12T10:49:35+00:00Added an answer on May 12, 2026 at 10:49 am

    Since __FUNCTION__ and __func__ is a predefined identifier and not a string literal, you cannot use it in preprocessor string literal concatenation. But you can use it in printf formatting. Also note the use of ##args instead of __VA_ARGS__ to use GNU style variadic macro arguments to work around the issue with the comma between __func__ and possibly zero args.

    #define DEBUG_WARNING(fmt, args...) \
      printf(">WARNING: %s() " fmt "\n", __func__, ##args)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So. I have a problem where I have two versions of GCC on a
when I get a compiler error (in my case gcc) in Emacs (version 23
I recently tried to use Qt Creator 1.3.2, Qt 4.6.2, and GCC 4.4.0 (32-bit
On my Linux platform, I have several versions of gcc . Under usr/bin I
I use the svn-version of the gcc-4.7.0 to check out some C++11 features, e.g.
I'm having a seemingly silly problem with my gcc compiler. I have installed MinGW
I am trying to use the GCC pragma optimize to set global optimizations in
I found that different compiler optimization levels in gcc give quite different results when
I use gcc version 4.3.2 (Debian 4.3.2-1.1). I wrote a simple program in C
I am running g++(gcc version 3.4.4) on cygwin. I can't get this small snippet

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.