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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T11:23:53+00:00 2026-05-11T11:23:53+00:00

On a software project (some old C compiler) we have a lot of variables

  • 0

On a software project (some old C compiler) we have a lot of variables which have to be saved normal and inverted.

Has somebody a idea how i can make a macro like that?

SET(SomeVariable, 137); 

which will execute

SomeVariable = 137; SomeVariable_inverse = ~137; 

Edit:

The best Solution seems to be:

#define SET(var,value) do { var = (value); var##_inverse = ~(value); } while(0) 

Thanks for the answers

  • 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. 2026-05-11T11:23:53+00:00Added an answer on May 11, 2026 at 11:23 am

    One hazard I haven’t seen mentioned is that the ‘value’ macro argument is evaluated twice in most of the solutions. That can cause problems if someone tries something like this:

    int x = 10; SET(myVariable, x++); 

    After this call, myVariable would be 10 and myVariable_inverse would be ~11. Oops. A minor change to JaredPar’s solution solves this:

    #define SET(var,value) do { var = (value); var##_inverse = ~(var); } while(0) 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a windows installer project which installs some software (winform, service, mce addin).
I'm working on a software project for Emacs that has some tests that can
In reviewing some system software concepts, I'm looking through my old OS project done
I'm developing a commercial software project that has some sensitive JavaScript code. I know
We have a software package which is about 16 years old. It's gone through
I have a small software project with a couple clients. What I'm looking for
I'm working on a software project which several members are working from home and
I am trying to compile an old C++ software project in Code::Blocks using the
Which audio codec should I choose for my C# software development project where the
We're a team of students doing a software project. As some of us don't

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.