[cfe-dev] Windows patches

John Thompson john.thompson.jtsoftware at gmail.com
Fri Oct 9 13:12:11 PDT 2009


Here's another crack at the windows include paths patch, using the registry
this time, with a fall back to the environment (if perhaps run on a
non-Windows system), with another fall back to hard-coded paths (if the env
vars are not set).  I also added an extra path that is typically defaulted
on Windows, the PlatformSDK/Include path, where all the Windows headers are.

I rearranged the code to try to localize the #ifdefs a bit more, but rather
than try to create a common place for system related things, I punted and
just left them in the file for now.
On thing you might not like is the hack to the CMakeLists.txt files I put
in, for working around the problem including windows.h because of the /Za
option.  But if anyone knows a better way...

-John
On Thu, Oct 8, 2009 at 6:46 PM, Mike Stump <mrs at apple.com> wrote:

> On Oct 8, 2009, at 5:42 PM, John Thompson wrote:
>
>> Can you give me some pointers on how to do a platform-specific file?
>>
>
> Oh, there are lots of ways and llvm doesn't tend to have a beautiful way to
> do this...  but one way would be to arrange it like so:
>
> #ifdef _MSC_VER
> code
> #endif
>
> You can then just have it  built normally, and call the routines from the
> file from the other parts of the file.
>
> So, for example, take a concepts called filename path canonicalization
> (just to pick a windows difference between unix).
>
> Support/Paths.h:
>
>  char *canonicalize(char *);
>
> Support/UnixPaths.cpp:
>
>  #ifndef _MSC_VER
>  char *canonicalize(char *c) {
>    while (c[0] == '/' && c[1] == '/') ++c;
>    return c;
>  }
>  #endif
>
> Support/WinPaths.cpp:
>
>  #ifdef _MSC_VER
>  char *canonicalize(char *c) {
>    // ...
>  }
>  #endif
>
> another approach would be llvm/lib/System/Atomic.cpp, though, I'm not sure
> I really like that style as much.  In general, one wraps up the system
> specific bits they want behind a system independent api, use that api in the
> main code, and then in the implementation, one can hide the details.
>



-- 
John Thompson
John.Thompson.JTSoftware at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20091009/981a0d3f/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: windows_include_paths_3.patch
Type: application/octet-stream
Size: 10766 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20091009/981a0d3f/attachment.obj>


More information about the cfe-dev mailing list