C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

#defines

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C Language
View previous topic :: View next topic  
Author Message
raghu
Guest





PostPosted: Tue May 08, 2007 9:12 am    Post subject: #defines Reply with quote



Hello Everyone,

I am using macro functions in my project the code is
working correctly, But I have a doubt wheather the macro functions
creates a context switching as in the case of normal functions. For
example see the code below:

#define funct(dest, src) {\
for( i = 0; i< 10; i++ )\
dest += (src + i);\
}

main()
{

int i, k;

funct(k , 10);

printf(" %d", k);
}

In this case 'int i' was not declared in funct but it works. And if in
main() 'int i' was not declared and declared in funct defination also
it works. Is there any context switch happening.

Thanks in advance

Bye
Raghu
Back to top
Ian Collins
Guest





PostPosted: Tue May 08, 2007 9:12 am    Post subject: Re: #defines Reply with quote



raghu wrote:
Quote:
Hello Everyone,

I am using macro functions in my project the code is
working correctly, But I have a doubt wheather the macro functions
creates a context switching as in the case of normal functions. For
example see the code below:

Macros are simple text substitution.


Functions DO NOT cause a context switch, I think you are getting your
terminology in a muddle.

--
Ian Collins.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C Language All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.