This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
RE: Understanding Macro Pre-processor
- From: "Rupert Wood" <me at rupey dot net>
- To: "'Bruno Moreira Guedes'" <thbmatrix at gmail dot com>
- Cc: <gcc-help at gcc dot gnu dot org>
- Date: Fri, 21 Sep 2007 11:48:17 +0100
- Subject: RE: Understanding Macro Pre-processor
- References: <3fdd6ce00709201319r706cc1eem8b63d9d77b85ceab@mail.gmail.com>
Bruno Moreira Guedes wrote:
> The mul(a,b) is replaced by a*b;
>
> But... Why executing that a milion of times is faster than using the
> simple a*b itself???
> It really happens? Why?
The best way to investigate this yourself would be to use gcc -S to generate the assembly listing for the mul(a,b) version and a*b version and see what's changed.
That said, I can't reproduce this - I get identical assembly produced from this test case (based on your snippet) whether I use the macro or not.
#include <iostream>
#define mul(X,Y) (X*Y)
int main(void)
{
int a,b,c;
std::cin >> a;
std::cin >> b;
c = mul(a,b);
std::cout << c << std::endl;
return 0;
}
And as far as I know and as far as I can see there's no 'mul' STL macro or template you're accidentally running into.
If you did intend to file a bug about this you'd need to tell us what CPU and OS you're using, what version of GCC this is and the command line you used - in particular which optimisation flags - and a complete, compilable test case.
Rup.
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________