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?

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top