1

I generated a loader with http://glad.dav1d.de/

  • Language: C/C++
  • GL: Version 4.5
  • Profile: Core

When I include glad.h in any file, variable names of near and far can't be used. It results in an expected an identifier, and Error C2513 no variable declared before '=' on Visual Studio 2015 on Windows 10.

#include <glad\glad.h>

int main()
{
    float near = 1.0f;
    char far = 2.0f;

    return 0;
}

The only place where I could find near and far in glad.h

typedef void (APIENTRYP PFNGLDEPTHRANGEPROC)(GLdouble near, GLdouble far);
GLAPI PFNGLDEPTHRANGEPROC glad_glDepthRange;
Alex
  • 3,111
  • 6
  • 27
  • 43
  • I guess that those identifiers are used somewhere in your `glad.h` file... – Rames Jan 21 '16 at 18:55
  • @Rames In a function pointer declaration... – Alex Jan 21 '16 at 18:56
  • 1
    It seems VC++ have some backward compatibility to old DOS code where compilers used to have such keywords as extensions. It's probably macros that expands to nothing these days though (which means the declarations look like e.g. `float = 1.0f;`) – Some programmer dude Jan 21 '16 at 18:57
  • It was working for the past 3 weeks until I switched to GLAD today from GLEW – Alex Jan 21 '16 at 18:58
  • 2
    Then maybe the GLAD headers include some system header that defines those macros, some header that GLEW didn't include? – Some programmer dude Jan 21 '16 at 19:00
  • By the way, you can easily check what the preprocessor generates, there are flags to only preprocess the source, then open the preprocessed file and see what the compiler sees. – Some programmer dude Jan 21 '16 at 19:03
  • 1
    @JoachimPileborg You're right. I found it. It's in `windef.h`. There's macros for `near`, `far`, `pascal`, `FAR`, and `NEAR`... All of them causes the same errors – Alex Jan 21 '16 at 19:05

1 Answers1

0

It seems that these names are defined as macros in the header or in a header that is included by this header

Usually these names are used for defining so-called near and far addresses.

Vlad from Moscow
  • 301,070
  • 26
  • 186
  • 335