WinMain taken from docs can't be compiled

101 views Asked by At

I have the following declaration of WinMain.

int CALLBACK WinMain(
  HINSTANCE hInstance,
  HINSTANCE hPrevInstance,
  LPSTR lpCmdLine,
  int nShowCmd
)

This compiles, however it generates the following warning.

Warning C28251 Inconsistent annotation for 'WinMain': this instance has no annotations

I tried to specify input / output attributes like this.

int CALLBACK WinMain(
  _In_ HINSTANCE hInstance,
  _In_ HINSTANCE hPrevInstance,
  _In_ LPSTR lpCmdLine,
  _In_ int nShowCmd
)

That didn't help so I changed the attribute for hPrevInstance as suggested by this answer.

int CALLBACK WinMain(
  _In_ HINSTANCE hInstance,
  _In_opt_ HINSTANCE hPrevInstance,
  _In_ LPSTR lpCmdLine,
  _In_ int nShowCmd
)

That didn't help so I looked at the docs which uses in as an attribute. So I changed the declaration once again.

int CALLBACK WinMain(
  in HINSTANCE hInstance,
  in HINSTANCE hPrevInstance,
  in LPSTR lpCmdLine,
  in int nShowCmd
)

But guess what. I got an error this time.

C2065 'in': undeclared identifier

Here is an example file.

#include <sb7/sb7.h>

struct App : public sb7::application {
    void render(const double time) {
        GLfloat color[] = { 1.f, 1.f, 1.f, 1.f };
        glClearBufferfv(GL_COLOR, 0, color);
    }
};

DECLARE_MAIN(App);

The sb7 library is taken from GitHub. The WinMain declaration is located in the library source code.

The MSVC version is 193431937.

How do I remove the warning about inconsistent annotations and compile WinMain successfully?

0

There are 0 answers