[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 255
  • 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

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

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