Question

does anyone know why this doesnt work?

void test() [[stdcall]] {
        std::cout << "Hello World" << std::endl;
}

when I try to compile with C++11 dialect it says:

"warning: 'stdcall' attribute directive ignored [-Wattributes]"

Why is that? I have a function that really needs to have the stdcall calling convention. The default calling convention in GCC is cdecl. Any suggestions?

Was it helpful?

Solution

The following should work:

#include <iostream>
[[gnu::stdcall]]
void test()
{
  std::cout << "Hello World" << std::endl;
}

or you can use the old syntax __attribute__((stdcall)). Compiling with g++ -std=c++11 -m32 I get no warning.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top