I need to know about the difference between intrinsic, inline and external function in C/C++ programming. Thnx for help ^^
-
6There's no language C/C++. – πάντα ῥεῖ Feb 17 '17 at 08:05
-
and to complete what @πάνταῥεῖ said, the expression `C/C++` is UB in both C and C++. :) – Sourav Ghosh Feb 17 '17 at 08:26
-
1@πάνταῥεῖ Are you saying that C and C++ differ with regards to this particular question? If they don't I really don't see the need to have one question for each language. – Klas Lindbäck Feb 17 '17 at 09:06
1 Answers
Intrinsic functions
Are functions which the compiler implements directly when possible instead of calling an actual function in a library. For example they can be used for optimization or to reach specific hardware functionality.
For ARM their exist an intrinsic function (and many others) called "__nop()" which inserts a single NOP (No Operation) instruction.
See the following links for more information
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0205g/Ciabijcc.html
https://en.wikipedia.org/wiki/Intrinsic_function
Extern functions
Tells the compiler that something is defined elsewhere, so it doesn't complain about being undefined or becoming multiply defined
Although there is almost never any need to use the keyword extern when declaring a function in C or C++ since they normally are linked this way by default.
See the following links for more information
http://www.cplusplus.com/forum/general/21368/
Inline functions
Inline functions is an optimization technique used by the compilers, especially to reduce the execution time. For example, if you have a small function (not declared as inline) with one input parameter and you call this function multiple times. The processor will (among other things)
- Save the parameter
- Jump to the function
- Execute the function
- Store result (if any)
- Jump back to previous position
Instead if the function was inline it would replace the call statement with the function code itself and then compile the code.
See the following links for more information
http://www.cplusplus.com/articles/2LywvCM9/
https://en.wikipedia.org/wiki/Inline_function
http://www.cprogramming.com/tutorial/lesson13.html
There are several more links available on major search engines.
-
3While link only answers are frowned upon, this one shows more effort than the op! +1 – Colin Feb 17 '17 at 08:09
-
1thnx for yr reply, but do not understand how to use of intrinsic function? Can you give me an exampl , please ? – SES Feb 17 '17 at 08:26
-
@Colin__s This is not how this works.... Luckily the answer got expanded – Kami Kaze Feb 20 '17 at 08:37
-
So inline and intristic are basically the same thing? Only difference is that intristic is predefined by compiler but inline is user defined funcs? – ScienceDiscoverer Aug 12 '22 at 07:15