Mixed _WIN32/WIN32 definitions causes compiler error over mkdir defintion in verilated.cpp in Visual Studio
I get the following compile error when compiling verilated.cpp in Visual Studio. Error C2039 'mkdir': is not a member of '`global namespace'' verilated.cpp 1783
The offending code seems to be here. Visual Studio defines _WIN32 and not WIN32 so it doesn't include direct.h and has no definition for mkdir. Looks like this was added in changeset c93d28050 recently, so presumably this was tested in a cygwin environment that defines both.
#if defined(WIN32) || defined(__MINGW32__) # include <direct.h> // mkdir #endifEasy enough to define WIN32 in Visual Studio, but probably confusing to figure out that's what's needed. Probably as easy as changing to the following, assuming this doesn't break on cygwin environments:
#if defined(WIN32) || defined(__MINGW32__) # include <direct.h> // mkdir #endif
#2 Updated by Benjamin Gartner 3 months ago
Oops.I actually meant
#if defined(_WIN32) # include <direct.h> // mkdir #endifbecause I'm not sure why we need to check WIN32 || or MINGW32 here. Everywhere else in the codebase uses the symbol _WIN32 and that worked fine for me when I built it under MSYS2, but I'm no expert on cygwin. But your proposed version would certainly fix the issue under Visual Studio. I just don't know if the other boolean terms are actually necessary.
Thanks for the response!
Also available in: Atom