Including windows.h, include paths

I was taking a crack at modifying Frontend/InitHeaderSearch.cpp to use the Windows registry to find the Visual Studio installation directory, but find that because of the /Za option used via cmake (disables Microsoft extensions - ANSI only), windows.h won’t compile.

As an experiment I took out the /Za option from the clang/CMakeLists.txt file, but recompiling revealed some compile errors in some string class.

Any thoughts on either how to make this work, or whether I should even be trying to read the registry?

Note that using the registry would solve the problem of not being able to see the environment variables when the tests are run.

I suppose I could hack up my own declarations for the needed registry symbols, but that sounds bad.

On a related note, should not InitHeaderSearch also be using the target triple information to determine which include path to use? I’ve enclosed a patch that attempts to do it. This would be important for cross-compiling, I gather. It also has revised code for getting the Visual Studio include path from the environment, plus the disabled code for the registry stuff.

-John

I was taking a crack at modifying Frontend/InitHeaderSearch.cpp to use the Windows registry to find the Visual Studio installation directory, but find that because of the /Za option used via cmake (disables Microsoft extensions - ANSI only), windows.h won't compile.

As an experiment I took out the /Za option from the clang/CMakeLists.txt file, but recompiling revealed some compile errors in some string class.
Any thoughts on either how to make this work, or whether I should even be trying to read the registry?

I think that using the registry to find Visual Studio is exactly the right solution. If the code that includes windows.h is segregated into a separate .cpp file, we can add whatever /Z??? flag is needed to make that one file handle windows.h

On a related note, should not InitHeaderSearch also be using the target triple information to determine which include path to use? I've enclosed a patch that attempts to do it. This would be important for cross-compiling, I gather. It also has revised code for getting the Visual Studio include path from the environment, plus the disabled code for the registry stuff.

I agree that InitHeaderSearch should use target triple information to determine which include paths to use.

  - Doug