For functions declared with the naked
attribute, the compiler generates code
without prolog and epilog code. You
can use this feature to write your own
prolog/epilog code sequences using
inline assembler code. Naked functions
are particularly useful in writing
virtual device drivers.
__declspec(naked) declarator
What is “prolog and epilog code”. I seen a libraries written in C code running on device or firmware using only libc. It calls functions without a problem, what does the naked keyword do and why is it needed?
note: I’m unsure what calling convention the functions use in those libs.
Prolog and epilog code is the first/last few instructions where it sets up the call stack. You use naked when you’re implementing something like an interrupt routine, where you need strict control over exactly what instructions appear in that function.