Search code examples
cgccstackpushiar

Similar to IAR __stackless for GCC


Is there a function attribute in GCC which acts as __stackless in IAR?

I've been looking for it and didn't find anything...

Thanks in advance Regards,

Victor.


Solution

  • I would use a combination of naked and noreturn.

    __attribute__((naked,noreturn,optimize("-O3")))

    extern int *x;
    
    void __attribute__((naked,noreturn,optimize("-O3"))) foo(int a, int b)
    {
        for(int c = a; c < b; c++)
        {
            x[c] = c * a;
        }
    }
    

    https://godbolt.org/z/xf9YKa