_wfopen was not declared in this scope


Version/Branch of Dear ImGui:
Back-end file/Renderer/OS:
sdl + opengl2 + imgui
windows 8

My Issue/Question:
when compiling imgui.cpp, there is an error which said that _wfopen is not declared in this scope

build log:
imgui.cpp: In function ‘FILE* ImFileOpen(const char*, const char*)’:
imgui.cpp:1612:69: error: ‘_wfopen’ was not declared in this scope
return _wfopen((wchar_t*)&buf[0], (wchar_t*)&buf[filename_wsize]);

what should I do to tackle this problem? I apologize for any inconvenience caused if I have missed something important.



Which compiler and vesion are you using?
As I understand it, Codeblocks is an IDE and it is calling into a compiler.

In the ImFileOpen() code we try to detect if the compiler and standard library has _wfopen() available, it seems like in your case it doesn’t have it, but we would need more information to decide on how we can alter that code.


ops, sorry for making such a mistake. I am using GNU GCC Compiler so i think it is the reason behind the issue. Should I use visual studio instead of Codeblocks? I love using Codeblocks but if there is no choice I would not mind switching to a new platform.

Thank you for your quick response.


No I think it is fine if you use GCC, it’s just hard to tell exactly what to test for in the code (in theory someone could be using GCC with a standard library that had _wfopen? I don’t really know…)

Pushed a tentative fix. Try to update and compile now!


thank you for updating. The issue has been solve but a new problem comes out lol. It pointed out that there are multiple definitions of vsnprintf. From the debugger, it said vsnprintf is first defined in stdio.h. What should I do to solve the issue?

Again, thank you very much for altering code and helpful advices.


I think this questions comes from a point of misunderstanding the C++ compiling and linking process rather than being an imgui related. You may get better answers on other programming.forum where people can point you to more helpful resources.