Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 256
  • Last Modified:

Macros

why does the macro increment or decrement twice before it evalutes,when we pass a increment or decrement operator as a parameter?
eg:#define macro(a) (a)*(a)

in the main function
   macro(++a);
0
Ramprasad_Inala
Asked:
Ramprasad_Inala
  • 3
1 Solution
 
rbrCommented:
A macro is just the source replacement


macro (++a) produces the source

(++a)*(++a) so a will be inremented twice.


0
 
rbrCommented:
And pls read
http://www.eskimo.com/~scs/C-faq/q3.2.html

This code is not well defined and can produce any result.
0
 
rbrCommented:
An pls give a comment to your other question
http://www.experts-exchange.com/jsp/qShow.jsp?ta=cprog&qid=10326206 
0
 
ozoCommented:
You can't depend on a being incrementyed twice, because an object shall be modified at most once between sequence points.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now