1 00:00:01,090 --> 00:00:07,540 When you call a function, the compiler will create a stack frame for the new function call and it will 2 00:00:07,540 --> 00:00:10,090 push items onto the stack here. 3 00:00:10,090 --> 00:00:19,480 So the data itself, the data put on the stack depends on your compiler, the whether the code is compiled 4 00:00:19,480 --> 00:00:22,060 for the debug or the release build here. 5 00:00:22,060 --> 00:00:30,490 So however, in general the there will be information about the parameters passed here, the information 6 00:00:30,490 --> 00:00:37,690 pass parameters and to the function, the return address here and the address, the name of the function 7 00:00:37,690 --> 00:00:42,100 call here and the automatic variables are located in this function here. 8 00:00:42,100 --> 00:00:47,440 This means that the when you make a function call at a runtime, there will be a memory overhead and 9 00:00:47,440 --> 00:00:53,770 performance overhead from creating the stack frame before the function runs and the performance overhead 10 00:00:53,800 --> 00:00:57,640 in when you clean this function up. 11 00:00:57,640 --> 00:00:59,590 So after the function completes here. 12 00:00:59,590 --> 00:01:06,230 So if a function is inline, this overhead does not occur because the function call will use the current 13 00:01:06,230 --> 00:01:08,180 stack frame rather than a new one. 14 00:01:08,180 --> 00:01:15,320 So clearly the inline function should be small, both in terms of code and the memory used on the stack 15 00:01:15,320 --> 00:01:24,410 here, so the compiler can ignore the inline specifier and call the function with a separate stack frame. 16 00:01:24,410 --> 00:01:29,450 So we can actually specify the call conventions in this cplusplus here. 17 00:01:29,480 --> 00:01:37,310 So when your code uses your own functions, you do not need to pay any attention to calling conventions 18 00:01:37,310 --> 00:01:42,140 because the compiler will make sure that the appropriate convention is used. 19 00:01:42,140 --> 00:01:49,970 So however, if you are writing library code that can be used by other cplusplus compilers or even by 20 00:01:49,970 --> 00:01:53,780 other languages, the calling convention becomes important. 21 00:01:53,780 --> 00:01:59,480 So since this course is not about interoperable code, we won't go into much depth here. 22 00:01:59,480 --> 00:02:05,930 But instead we will look at two aspects function naming and stack maintenance. 23 00:02:06,600 --> 00:02:09,390 So we can also use the C linkage here. 24 00:02:09,660 --> 00:02:15,840 So when you give a C plus plus function a name, this is the name that you will use to call the function 25 00:02:15,840 --> 00:02:18,060 in your C plus plus code. 26 00:02:18,090 --> 00:02:24,810 However, under the covers, the C plus plus compiler will decorate the name with the extra symbols 27 00:02:24,810 --> 00:02:31,890 for the return type and the parameter so that the overloaded functions all have different names. 28 00:02:31,890 --> 00:02:34,730 So to the C plus plus developers. 29 00:02:34,740 --> 00:02:41,430 This is also known as the name mangling mangling. 30 00:02:41,430 --> 00:02:48,060 So if you need to export a function through the shared library, for example, in Windows Dynamic Link 31 00:02:48,090 --> 00:02:54,150 library, this means that that dll files for the. 32 00:02:56,590 --> 00:03:04,570 Shared library library in windows here that dll files here. 33 00:03:04,570 --> 00:03:07,420 So this means dynamic link library. 34 00:03:07,420 --> 00:03:12,010 So you must use the types and names that the other languages can use. 35 00:03:12,010 --> 00:03:19,690 So to do this you can mark a function with the extension C here, this means that function has C linkage 36 00:03:19,690 --> 00:03:28,480 and the compiler will not use the external code and you should not use it with the function that have 37 00:03:28,480 --> 00:03:37,360 return values and parameters that use the C plus plus custom types extern C here like that. 38 00:03:37,360 --> 00:03:38,500 So. 39 00:03:39,790 --> 00:03:46,660 However, if such function does return a cplusplus type, the compiler will only use a warning. 40 00:03:46,690 --> 00:03:54,850 The reason is that the C is a flexible language and the C programmer will able to work out how to turn 41 00:03:54,850 --> 00:03:57,850 the Cplusplus type into something usable. 42 00:03:57,850 --> 00:04:01,890 But it's poor practice to abuse them like this here.