[Solved] Difference between intrinsic, inline, external in embedded system? [closed]


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

What are intrinsics?

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

Extern functions in C vs C++

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)

  1. Save the parameter
  2. Jump to the function
  3. Execute the function
  4. Store result (if any)
  5. 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.

4

solved Difference between intrinsic, inline, external in embedded system? [closed]