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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:12:43+00:00 2026-05-16T05:12:43+00:00

I’m working on a project that uses lots of external libraries. Now, I like

  • 0

I’m working on a project that uses lots of external libraries. Now, I like my projects to compile with the highest warning level available, which on MSVC is /W4. I’m also using -Wall on GCC for this project, which needs to be cross-platform.

With /W4, I’m hitting a problem: I’m often including the headers of the other libraries, and those headers were not written to conform to /W4 (that is, they throw lots of warnings). There’s nothing I can do about them so I’d rather not see them. They just end up as noise.

Currently I’m doing this to temporarily lower the warning level:

#if defined(_MSC_VER)
#   pragma warning( push, 3 )
#endif

#include <SomeExternalHeader.h>

#if defined(_MSC_VER)
#   pragma warning( pop )
#endif

Including these six lines for every (different) group of external headers I want to include across the various files is getting tiresome. Can I somehow #define a macro that I can then use for these external headers? I’d like something like the following:

INCLUDE_EXTERNAL_HEADER(<SomeExternalHeader.h>)

This would then wrap the #include with the required lines. Is this possible? My gut instinct tells me that wouldn’t work because it would require running the preprocessor twice.

What would be the best way to deal with this problem?

  • 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-16T05:12:43+00:00Added an answer on May 16, 2026 at 5:12 am

    I’m not aware of a single line solution like the one you want but MSVC does have a __pragma keyword that you can use inside a preprocessor macro.

    So you can do something like this:

    #if defined(_MSC_VER)
    # define SET_LOWER_WARNING_LEVEL       __pragma(warning(push, 3))
    # define RESET_DEFAULT_WARNING_LEVEL   __pragma(warning(pop))
    #else 
    # define SET_LOWER_WARNING_LEVEL       //gcc directive 
    # define RESET_DEFAULT_WARNING_LEVEL   //gcc directive
    #endif
    
    SET_LOWER_WARNING_LEVEL
    #include "HeaderGeneratingWarnings.h"
    RESET_DEFAULT_WARNING_LEVEL
    

    P.S.: I’ve never used the __pragma form so I don’t know for sure whether the pragma directive syntax above is correct.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into

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.