This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Understanding Macro Pre-processor


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 
______________________________________________________________________


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]