8

When I compile the following C source with gcc version 8.1.1, I get a warning: ‘stdcall’ attribute ignored [-Wattributes].

Why does gcc choose to ignore this attribute and what can I do to make it accept it?

__attribute__((stdcall)) int S(int a) {
    return a * (a+1);
}

int main() {
    return S(6);
}
2
  • What architecture are you compiling for? Commented Oct 9, 2018 at 5:27
  • 1
    Move to a 32-bit x86 platform. Commented Oct 9, 2018 at 5:27

1 Answer 1

8

The gcc documentation says:

stdcall

On x86-32 targets, the stdcall attribute causes the compiler to assume that the called function pops off the stack space used to pass arguments, unless it takes a variable number of arguments.

(Emphasis mine.)

So if you're not compiling for a 32-bit machine, stdcall can't be used.

Sign up to request clarification or add additional context in comments.

4 Comments

Is there a technical reason that stdcall is not possible on non-x86-32 targets?
@RenéNyffenegger x86-64 doesn't pass arguments on the stack (or rather, it prefers using registers before using the stack), so there's little point in defining and using different incompatible conventions for adjusting the stack.
Thanks for clearing that up to me. I was completely unaware of the shift between 32 and 64 bit x86 regarding calling conventions.
Is it possible to turn this warning off?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.