Invoking Functions

Let's first look at what actually happens when a function call is made. Previous chapters have already hinted at function-call overhead and now seems to be the ideal time to discover exactly what this so-called overhead is. Consider therefore the simple C/C++ function presented in Listing 8.1.

Code Listing 8.1. A Simple Add Function
int MyAddFunct(int a, int b, int c)
{
    return a + b + c;
}

void main(void)
{
    int a = 1, b = 2 , c = 3;
    int res =
						
						 MyAddFunct(a,b,c);
}

The function MyAddFunct in Listing 8.1 takes three integers as input and returns as a result the sum of the three. By compiling this source with the assembly output option turned on (see Chapter 4, "Tools and Languages" ), you can look at what the processor ...

Get C++ Footprint and Performance Optimization now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.