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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:19:05+00:00 2026-05-27T09:19:05+00:00

I’m trying to make this work (in GCC 4.6) without barking at me. #define

  • 0

I’m trying to make this work (in GCC 4.6) without barking at me.

#define FOO  ""
#define BAR  ""

#if ....
    #define FOO    "Foo, good sir"
#endif

#if ...
    #define BAR    "Bar, my lady"
#endif
....

#define EVERYTHING      FOO BAR ...

I am going to have a lot of these. So doing it that way instead of:

#if ...
    #define FOO    "Foo"
#else
    #define FOO    ""
#endif

Saves a lot of code, and makes it more readable. The warning that I get is:

warning: “FOO” redefined [enabled by default]

Is there a way to disable this warning in the code for this particular section? I found Diagnostic Pragmas to disable certain warnings, but I’m not able to find which warning (in this list of Options to Request or Suppress Warnings) that needs to be disabled here.

Anyone know how to do this? Or a different way to avoid having to #else #define all of them to the empty string?

  • 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-27T09:19:06+00:00Added an answer on May 27, 2026 at 9:19 am

    This warning comes from file named “cccp.c” in gcc (as of 2.95 version; is this file from “Soviet Russia”?), and it can’t be turned off. There is still no option to disable this warning individually even in git head, gcc/libcpp/macro.c file (line 2527 and line 2994 of the same file)

    I’ll cite sources a bit.

    2525 /* Returns nonzero if a macro redefinition warning is required.  */
    2526 static bool
    2527 warn_of_redefinition (cpp_reader *pfile, cpp_hashnode *node,
    2528                       const cpp_macro *macro2)
    2529 {
    ...
    2537   /* Suppress warnings for builtins that lack the NODE_WARN flag.  */
    ..
    2545   /* Redefinitions of conditional (context-sensitive) macros, on
    2546      the other hand, must be allowed silently.  */
    ...
    2550   /* Redefinition of a macro is allowed if and only if the old and new
    2551      definitions are the same.  (6.10.3 paragraph 2).  */
    ...
    2561   /* Check parameter spellings.  */
    ...
    2566   /* Check the replacement text or tokens.  */
    ...
    2573   for (i = 0; i < macro1->count; i++)
    2574     if (!_cpp_equiv_tokens (&macro1->exp.tokens[i], &macro2->exp.tokens[i]))
    2575       return true;
    

    So in your case warn_of_redefinition function will return true. And here is real usage:

    2989   if (node->type == NT_MACRO)
    2990     {
    2991       if (CPP_OPTION (pfile, warn_unused_macros))
    2992         _cpp_warn_if_unused_macro (pfile, node, NULL);
    2993 
    2994       if (warn_of_redefinition (pfile, node, macro))
    2995         {
    2996           const int reason = (node->flags & NODE_BUILTIN)
    2997                              ? CPP_W_BUILTIN_MACRO_REDEFINED : CPP_W_NONE;
    2998           bool warned;
    2999 
    3000           warned = cpp_pedwarning_with_line (pfile, reason,
    3001                                              pfile->directive_line, 0,
    3002                                              "\"%s\" redefined",
    3003                                              NODE_NAME (node));
    3004 
    3005           if (warned && node->type == NT_MACRO && !(node->flags & NODE_BUILTIN))
    3006             cpp_error_with_line (pfile, CPP_DL_NOTE,
    3007                                  node->value.macro->line, 0,
    3008                          "this is the location of the previous definition");
    3009         }
    3010     }
    

    So, there is no any specific option. And answer by Greg is good for this case, just undefine your empty string just before redefinition.

    • 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'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
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 am trying to render a haml file in a javascript response like so:
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

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.