Jimmyt1988
Jimmyt1988

Reputation: 21126

CreateWindow class method throwing expected a type specifier - windows.h

Take the following code:

# pragma once

// Windows specific files
#include <windows.h>
#include <stdlib.h>
#include <string.h>
#include <tchar.h>

#include "IOS.h"

namespace PlatformGameEngine
{
    class OSWindows : public IOS
    {
    public:
        virtual void CreateWindow( const WindowProperties windowProperties ) override;
    };
}

If i remove the #include <windows.h> the code compiles fine. If i keep it in, I get an error pop up under the virtual void CreateWindow part...

expected a type specifier

What's going on here? How do i solve it?

Upvotes: 1

Views: 294

Answers (1)

Mike Seymour
Mike Seymour

Reputation: 254461

CreateWindow is an evil macro. If you include the header that defines it, you can't use the name for any other purpose.

Either stop supporting Microsoft or, if you really must do that, choose a different name for your function. Or maybe add #undef CreateWindow and hope for the best.

Upvotes: 1

Related Questions