 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
raghu Guest
|
Posted: Tue May 08, 2007 9:12 am Post subject: #defines |
|
|
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
|
Posted: Tue May 08, 2007 9:12 am Post subject: Re: #defines |
|
|
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 |
|
 |
|
|
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
|
|