Exforsys

Online Training

Evaluation of Preprocessor Directive

This is a discussion on Evaluation of Preprocessor Directive within the C and C++ forums, part of the Programming Talk category; If I have #define defined as #define dividefunc(a,b) a/b and have a function call as dividefun(x+...


Go Back   Exforsys > Programming Talk > C and C++

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-05-2007, 06:29 PM
Senior Member
 
Join Date: Apr 2006
Posts: 144
caradoc is on a distinguished road
Evaluation of Preprocessor Directive

If I have #define defined as
#define dividefunc(a,b) a/b

and have a function call as
dividefun(x+2,y+3);

Suppose x=13 and y=2
How will the #define gets evaluated
Will it get substituted as
dividefun(13+2,2+2) which is equal to
dividefun(15,4)
and then get divided as 15/4 =4
or
will it get evaluated as
dividefun(x+2,y+2)
x+2/y+2 which is equal to
13+3/2+2 which becomes 13+1+2=16

Kindly let me know how the evaluation takes place
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 05-08-2007, 04:41 PM
Senior Member
 
Join Date: Apr 2006
Posts: 125
ashlee is on a distinguished road
It will get evaluated as
dividefun(x+2,y+2)
x+2/y+2 which is equal to
13+3/2+2 which becomes 13+1+2=16

This is because whenever a Preprocessor Directive is called the values given in parameters are substituted as such in the calling directive and then only operation takes place.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

Thread Thread Starter Forum Replies Last Post
trial version winrunner garima Testing Tutorials 4 07-10-2007 02:11 AM
QuickTest Professional 8.0 QTP Pro CBT Tutorial and Evaluation Copy admin Testing Tutorials 0 04-12-2005 04:38 PM
comp.lang.c Answers to Frequently Asked Questions (FAQ List) Steve Summit Tech FAQ 0 06-01-2004 07:00 AM


All times are GMT -4. The time now is 11:13 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2004 - 2007 Exforsys Inc. All rights reserved.