graphitemaster / glsl-parser

A GLSL parser
MIT License
251 stars 30 forks source link

parser.h seems to be playing badly with the windows API? #18

Open marc-weber1 opened 3 years ago

marc-weber1 commented 3 years ago

I'm not sure if this is an error in the code or some names interfering with the windows API, but it should be noted that #include "parser.h" defaults to including a file from the windows API, so it might need a slight name change.

Even when getting around this issue using something like compiling all the files as a static library and using #include "glsl-parser/parser.h", the following error crops up, and I'm not sure whether it's related to name interference with the windows API:

  glsl-parser.lib(parser.obj) : error LNK2019: unresolved external symbol "private: static void __cdecl glsl::astNode<s
truct glsl::astVariable>::operator delete(void *)" (??3?$astNode@UastVariable@glsl@@@glsl@@CAXPEAX@Z) referenced in fun
ction "public: void * __cdecl glsl::astVariable::`scalar deleting destructor'(unsigned int)" (??_GastVariable@glsl@@QEA
APEAXI@Z) [E:\Users\facade\Documents\Github\skybox-painter\build\skyboxpainter.vcxproj]
  glsl-parser.lib(parser.obj) : error LNK2019: unresolved external symbol "private: static void __cdecl glsl::astNode<s
truct glsl::astFunction>::operator delete(void *)" (??3?$astNode@UastFunction@glsl@@@glsl@@CAXPEAX@Z) referenced in fun
ction "public: void * __cdecl glsl::astFunction::`scalar deleting destructor'(unsigned int)" (??_GastFunction@glsl@@QEA
APEAXI@Z) [E:\Users\facade\Documents\Github\skybox-painter\build\skyboxpainter.vcxproj]

Is this issue reproducible on any platform other than windows x64? If so, is there any quick fix for it?

marc-weber1 commented 3 years ago

Forgot to post the code that caused the error:

#include "glsl-parser/parser.h"

glsl::parser shader_parser(fShaderCode, fragmentPath);
glsl::astTU *tu = shader_parser.parse(glsl::astTU::kFragment);
std::cout << tu->globals.size() << std::endl;
zhaocy1217 commented 2 years ago

//private: // void operator new(size_t); // void operator delete(void); commenting this two lines in ast.h may works.