clang::FileManager -> getFile returns NULL on Windows Visual Studio ### On Linux everything works fine

Hi everybody,

I just started hacking on a small command line tool and
when I try to get a file with the following code it always gives
me an empty address.

main.exe c:\test.c

The same code compiled and running on linux works just fine.

int main (int argc, char **argv)
{
int ret = 0;

clang::FileManager fm = new clang::FileManager(clang::FileSystemOptions());
const clang::FileEntry
file = fm->getFile(llvm::StringRef(argv[1]));

return(ret);
}

Is it a bug? I hope anybody can help me?

Thanks in advance,
Peter

I think that you problem is due to Clang’s assumption that all paths are in UTF8 and that’s not true for Windows, try converting your argv[1] to UTF8 and see if it helps.

Would you like to try not on the root directory?

See also; http://llvm.org/bugs/show_bug.cgi?id=10331

...Takumi

Would you like to try not on the root directory?
Yes, that worked … :slight_smile: Oh man, I should have tried it in the first place… :wink:

See also; http://llvm.org/bugs/show_bug.cgi?id=10331
So is it a bug…? Is there a workaround…?

Thanks so much for your help…!!!

Hii,

I still can’t read files from a root directory on Windows.
I am getting the following error

error: error reading ‘C:\test.c’

I’ve tried with the current llvm trunk and with the 3.1 and 3.0 version.
None of them worked. Any other path works just fine!!

Does anyone now what the problem might by?

Thanks in advance!!!
Peter

Peter, I believe I have fixed the issue in r158596.

...Takumi

Peter, I believe I have fixed the issue in r158596.
yheaaaaaaaa… :):slight_smile: Takumi, I just updated my svn brunch and it works now. Thanks so
much for your work!!!

Best regards from Germany!!