I use the __FILE__
macro for error messages. However, sometimes the path comes back as E:\x\y\/z.ext
. It does this for specific files.
For example, E:\programming\v2\wwwindowclass.h
comes back as E:\programming\v2\/wwwindowclass.h
and E:\programming\v2\test.cpp
comes back as E:\programming\v2\test.cpp
. In fact, the only file in the directory that works seems to be test.cpp
.
To work around this, I used jmucchiello's answer to this question to replace any occurrence of "/" with "\". This worked fine, and the displayed path changed to a normal one.
The problem was when I tried it on Windows 7 (after using XP). The string came up as (null)
after calling the function.
Along with this, I sometimes get some seemingly random error 2: File not found
errors. I'm unsure of whether this is related at all, but if there's an explanation, it would be nice to hear.
I've tried to find why __FILE__
would be returning the wrong string, but to no avail. I'm using GNU g++ 4.6.1. I'm not actually sure yet if the paths that were wrong in XP were wrong in Windows 7 too. Any insight is appreciated.