When you call a function, the compiler will create a stack frame for the new function call and it will
push items onto the stack here.
So the data itself, the data put on the stack depends on your compiler, the whether the code is compiled
for the debug or the release build here.
So however, in general the there will be information about the parameters passed here, the information
pass parameters and to the function, the return address here and the address, the name of the function
call here and the automatic variables are located in this function here.
This means that the when you make a function call at a runtime, there will be a memory overhead and
performance overhead from creating the stack frame before the function runs and the performance overhead
in when you clean this function up.
So after the function completes here.
So if a function is inline, this overhead does not occur because the function call will use the current
stack frame rather than a new one.
So clearly the inline function should be small, both in terms of code and the memory used on the stack
here, so the compiler can ignore the inline specifier and call the function with a separate stack frame.
So we can actually specify the call conventions in this cplusplus here.
So when your code uses your own functions, you do not need to pay any attention to calling conventions
because the compiler will make sure that the appropriate convention is used.
So however, if you are writing library code that can be used by other cplusplus compilers or even by
other languages, the calling convention becomes important.
So since this course is not about interoperable code, we won't go into much depth here.
But instead we will look at two aspects function naming and stack maintenance.
So we can also use the C linkage here.
So when you give a C plus plus function a name, this is the name that you will use to call the function
in your C plus plus code.
However, under the covers, the C plus plus compiler will decorate the name with the extra symbols
for the return type and the parameter so that the overloaded functions all have different names.
So to the C plus plus developers.
This is also known as the name mangling mangling.
So if you need to export a function through the shared library, for example, in Windows Dynamic Link
library, this means that that dll files for the.
Shared library library in windows here that dll files here.
So this means dynamic link library.
So you must use the types and names that the other languages can use.
So to do this you can mark a function with the extension C here, this means that function has C linkage
and the compiler will not use the external code and you should not use it with the function that have
return values and parameters that use the C plus plus custom types extern C here like that.
So.
However, if such function does return a cplusplus type, the compiler will only use a warning.
The reason is that the C is a flexible language and the C programmer will able to work out how to turn
the Cplusplus type into something usable.
But it's poor practice to abuse them like this here.