Levi
Levi

Reputation: 23

#include <windows.h> causes errors

I'm trying to use GetTickCount() from the windows.h header file. Right now my code looks like this:

#include <stdio.h>
#include <string.h>
#include "declarations.h"
#define INPUTBUFFER 400 * 6
#define START_POS "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"
#include <windows.h>

void interface() {
.....
.....
}

The compiler returns 2 errors:

  1. Expected '{' before '(' token (pointing to the '(' after "interface"
  2. 2 or more data types in declaration specifiers (pointing to "interface")

When I comment out #include < windows.h >, the interface function works just fine. I don't even have GetTickCount() in my code yet. I checked the gcc path to make sure windows.h is there, so I'm not sure why I'm getting this error.

Upvotes: 1

Views: 952

Answers (1)

plugwash
plugwash

Reputation: 10514

As RbMm points out in a comment, the windows headers contain "#define interface struct", so the compiler sees your code as "void struct() { ....}" which is not valid C++

You need to either rename your function (probablly the better option) or add a "#undef interface" before your function.

Upvotes: 1

Related Questions