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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:55:52+00:00 2026-05-23T14:55:52+00:00

I know how to disable all unknown #pragma warnings. The answer was given, for

  • 0

I know how to disable all unknown #pragma warnings. The answer was given, for example, in How can I disable #pragma warnings?.

Is there a way to disable an ‘unknown pragma’ warning for one particular pragma? For example, if I disable warning for #pragma ugubugu the following code:

#pragma ugubugu
#pragma untiunti

int main() {return 0;}

when compiled with either:

g++ pragma.cpp -Wall
clang++ pragma.cpp -Wall

should produce a single warning:

warning: ignoring #pragma untiunti

Maybe, for example, is there a simple way to register a custom pragma which would do nothing?

It would be great to know if there is such an option is Visual Studio too, but that is less important.


"But why ultimately is he playing with custom pragmas?"

My source code is parsed by two compilers. In one of those, there is a special #pragma that is unknown to the other. Of course, I could probably put #ifdef COMPILER_IDENTIFICATION_MACRO ... #endif around every instance of the #pragma, but that would be cumbersome.

  • 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-23T14:55:52+00:00Added an answer on May 23, 2026 at 2:55 pm

    I’m reasonably sure that there isn’t any way to do this.

    Both GCC and Clang do have internal interfaces which allow the language frontend to register #pragma handlers with the preprocessor – see GCC’s libcpp/directives.c and Clang’s lib/Lex/Pragma.cpp – but, as far as I can see, there is nothing which lets you modify which handlers are registered (beyond what is implied by the language variant you’re compiling for) based on command line options.

    I know how to disable all unknown #pragma warnings. The answer was given, for example, here: SO: How to disable #pragma warnings?

    Note that the highest voted answer is better than the accepted one there. -Wno-unknown-pragmas can simply be added on the command line after anything (like -Wall) which turns the warning on.

    My source is parsed by two compilers. In one of those, there is a special #pragma, that is unknown to the other. Of course, I could probably put #ifdef COMPILER_IDENTIFICATION_MACRO ... #endif around every instance of the #pragma but that would be cumbersome.

    From a more philisophical viewpoint, I think this is really the right solution, cumbersome though it may be!

    It seems correct to me to hide any #pragma from a compiler which is not expected to understand it in the way that you intend, given that the whole point of #pragma is to provide a mechanism for invoking implementation-defined behaviour in the compiler.

    (If you do end up doing this, note that Clang defines __clang__, but both GCC and Clang define __GNUC__.)

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

Sidebar

Related Questions

You know the one I mean: Is there a way to disable this? I'm
I would like to know if there is a way to disable automatic loading
I know this sounds bad but how can I disable/suppress a specific warning for
How can I disable all MSVC warnings that come from the boost library? I
We all know the good old disable the submit button trick but what are
I wanted to know the way to disable a function from usage in PHP.
I know this seams a trivial question, but how can I disable the annoying
I know that rsync can enable / disable the ssh encryption protocol during the
First of all, I know that the error I am getting can be resolved
I know that the UIMenuController can show a popover containing Cut, Copy, Paste, Select/All,

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.