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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:14:55+00:00 2026-05-30T01:14:55+00:00

I am currently working on an already developed project written in MFC C++ and

  • 0

I am currently working on an already developed project written in MFC C++ and am facing a problem with an already present macro having the definition:

#define HEIGHT_TESTS 13

I am trying to change the value from within the code but I think since its a preprocessed definition, I am unable to do that. Is there a way I could get around this problem without having to change the original macro overall (as it might affect the original functionality of the program). I am just intending to change it in one particular condition, rest everywhere else it remains the same.

Just to let everyone know, I have obviously tried out using a different macro definition with the value (17) I am intending to use, but no luck as such.

Any help would be much appreciated.

  • 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-30T01:14:57+00:00Added an answer on May 30, 2026 at 1:14 am

    You can undefine it and define again:

    #include <iostream>
    
    #define AAA 13
    
    int main()
    {
        #undef AAA
        #define AAA 7
        std::cout << AAA;
    }
    

    outputs: 7

    Please note that statements that start with # are preprocessor directives that are taken care of before the code is even compiled. In this case, this constant AAA will be simply replaced by 7, i.e. it works just like a textual replacement with no additional checks of syntax, no type safety etc…

    …which is main reason why you should avoid using macros and #defines where they can be replaced by static functions and variables 🙂


    Why “textual replacement” ?

    Look at this code:

    #include <iostream>
    
    #define AAA 13
    
    void purePrint() {
        std::cout << AAA;
    }
    
    void redefAndPrint() {
        #undef AAA
        #define AAA 7
        std::cout << AAA;
    }
    
    int main()
    {
        #undef AAA
        #define AAA 4
        purePrint();
        redefAndPrint();
        purePrint();
    }
    

    preprocessor goes line by line from the top to the bottom, doing this:

    • ah, #define AAA 13, so when I hit AAA next time, I’ll put there 13
    • look, purePrint uses AAA, I’m replacing it with 13
    • wait, now they tell me to use 7, so I’ll stop using 13
    • so here in redefAndPrint() I’ll put there 7

    transforming the given code into this one:

    #include <iostream>
    
    void purePrint() {
        std::cout << 13;
    }
    
    void redefAndPrint() {
        std::cout << 7;
    }
    
    int main()
    {
        purePrint();
        redefAndPrint();
        purePrint();
    }
    

    which will output 13713 and the latest #define AAA 4 won’t be used at all.

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

Sidebar

Related Questions

I am currently working on a large project. It is already lunched but the
I'm currently working on a symfony webapp, which is already on production. To develop
Currently I am working with: C# Windows forms application I currently have a problem
I'm working on a project that currently has zero users but we would like
I'm currently working on an already modified version of magento (v 1.6.1). The previous
I'm currently running my Selenium through PHPUnit. The project I'm working on has multiple
I'm currently working on a project to re-develop a public sector website. The website
I'm currently working on an Intranet application project, using ASP.NET MVC 3. One of
I'm currently working on an client application developed using winforms on .Net 2.0. Are
I am working on an Android application which works with JNI, with already developed

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.