I want to use a naked function in my C++ program using g++. Unfortunately g++, unlike VC++, does not support naked functions and the only way to manage this is to write your
Here's an example of a trick to achieve the "naked function" effect.
#include extern "C" int naked_func (); static void dummy () { __asm__ __volatile__ ( " .global naked_func\n" "naked_func:\n" " movq $3141569, %rax\n" " ret\n" ); } int main () { printf ("%d\n", naked_func ()); return 0; }