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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:45:08+00:00 2026-06-14T06:45:08+00:00

Is there a generic suppress warning that i can use? The problem is that

  • 0

Is there a generic suppress warning that i can use?

The problem is that there are times i may build using one compiler version (gcc) and then i have a partner that uses some of the common things but uses a different compiler. So the warning # are different.

The only way i could think of doing was making a macro that was defined in a file that i would pass in some generic value:

SUPPRESS_WARNING_BEGIN(NEVER_USED)
//code
SUPPRESS_WARNING_END

then the file would have something like:

#if COMPILER_A
    NEVER_USED = 245
#endif

#if COMPILER_B
    NEVER_USED = 332
#endif


#define SUPPRESS_WARNING_BEGIN(x) /
     #if COMPILER_A
        //Compiler A suppress warning x
     #endif

     #if COMPILER_B
        //Compiler B suppress warning x
     #endif

#define SUPPRESS_WARNING_END /
     #if COMPILER_A
        // END Compiler A suppress warning
     #endif

     #if COMPILER_B
        // END Compiler A suppress warning
     #endif

Don’t know if there is an easier way? Also i know ideally we all would just use the same compiler but that is unfortunately not an option. Just trying to find the least complicated way to support something like this and am hoping there is a simpler way then mentioned above.

thanks

  • 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-14T06:45:09+00:00Added an answer on June 14, 2026 at 6:45 am

    There’s no portable way to do that. Different compilers do it in different ways (e.g. #pragma warning, #pragma GCC diagnostic, etc.).

    The easiest and best thing to do is to write code that does not generate any warnings with at compiler at any warning level.

    If your goal is to suppress warnings about unused variables, I recommend using a macro:

    #define UNUSED(x) ((void)sizeof(x))
    ...
    void some_function(int x, int y)
    {
        // No warnings will be generated if x is otherwise unused
        UNUSED(x);
        ....
    }
    

    The sizeof operator is evaluated at compile-time, and the cast to void produces no result, so any compiler will optimize the UNUSED statement away into nothing but consider the operand to be used.

    GCC also has the unused attribute`:

    // No warnings will be generated if x is otherwise unused
    int x __attribute__((unused));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to utilize ftp? Is there a generic dll that I can use for
Is there a generic "form sanitizer" that I can use to ensure all html/scripting
Is there a generic way to retrieve a database schema using ODBC that works
UIView has a setNeedsDisplay method that one can call several times within the same
Is there a generic way I can get a post-build event to copy the
Is there any generic alternative / implementation for MemoryCache? I know that a MemoryCache
Is there a generic TimeZoneInfo for Central Europe that takes into consideration both CET
Is there a limit on the amount of generic parameters you can have on
Is there a way to make this method generic so I can return a
Is there any generic command or syntax in SQL to allow one to have

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.