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

  • Home
  • SEARCH
  • 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 8488539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:33:59+00:00 2026-06-10T21:33:59+00:00

I noticed that a flag I defined as -D__SOME_FLAG=1 on the compile line(g++), when

  • 0

I noticed that a flag I defined as -D__SOME_FLAG=1 on the compile line(g++), when used in a header file, did not seem to have the desired affect. ie: code that was enclosed within a #ifdef __SOME_FLAG ... #endif, did not seem to be compiled. I can always use a #define within the headers, to make this work. But ideally , I want to be able to make a change in one place(ie: the Makefile).

I wanted to know if what I am trying is possible?

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-10T21:34:01+00:00Added an answer on June 10, 2026 at 9:34 pm

    Yes, it should be possible and the -D flag is exactly for that.

    Please check http://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html#Preprocessor-Options

    From what I read there, maybe you should use -D symbol=value with a space between them, or -D"symbol=value" with quotes.. I didn’t try however as my laptop’s battery is currently dying:)

    edit:
    Sorry, just remembered that on linuxes there should be no space, so your commandline with -D__SOME_FLAG=1 should be correctly setting “__SOME_FLAG” to 1. If you are not on linux but windows, you caould try with space, but I doubt. Also, if the GCC is old or funky, it may actually ignore the first character after -D and so a “_SOME_FLAG” could be defined instead. I’ve seen it a few times but only on some very buggy ports..

    btw. Maybe something other #undefs it? Or maybe you have forgotten to add that flag to all compilations of all files? -D options are used only on the file(s) currently compiled, so if you have a several gcc invocations in your Makefile, you might have added the flag only to some of them. That was usually my issue, as I tend to put the -I and -D flags only on first, and forget about the other modules..

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

Sidebar

Related Questions

I have noticed that when I call the /install flag on NServiceBus.host.exe an event
I have noticed from the llvm source code that the compiler supports the flag:
I noticed that IE 9 does not support application cache. How can I use
I noticed that static assertions in class templates are not triggered when instantiations are
I noticed a lot of Android functions have a parameter that you can pass
I was playing with wx.Frame.SetWindowStyleFlag() and noticed that to add a new flag I
I am writing a download file utility using WinINET, and have noticed (especially on
I would like to compile fortran code on mac such that it does not
I've noticed something about my coding that is slightly undefined. Say we have a
I noticed that the <td align=center> code works differently on the MediaWiki.org page and

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.