Duplicated header between Clang and MSVC - why?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Duplicated header between Clang and MSVC - why?

Renato Golin via cfe-dev

Hello Clang-Experts,

 

I’m using Clang-CL in Visual Studio – everything is working fine! Hooray!

But recently I noticed that some header files related to the C-Library are duplicated on my hard drive. For example: stddef.h – so I searched for it and noticed, that Visual Studio has like… 5 of them, but all related to different versions of MSVC. That made sense to me, but then: surprise! I also have that file under “C:\Program Files\LLVM9\lib\clang\9.0.0\include” being obviously related to Clang. I also noticed that there are many files duplicated between Clang and MSVC.

 

Now I wonder… If I run Clang-CL, should I use the most up to date MSVC header or the Clang one?

Why are these files duplicated anyway?

 

I feel like, that this is a silly question, but I seriously have no idea.

 

Kind greetings

Björn

Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Heiko Lampert, Takashi Nagano, Takeshi Fukushima. Junichi Tajika
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Duplicated header between Clang and MSVC - why?

Renato Golin via cfe-dev
Certain low level headers are very tightly tied to the compiler implementation (containing compiler intrinsics, etc) - so they have to be provided by/paired with the compiler.

On Tue, Oct 1, 2019 at 11:58 PM Gaier, Bjoern via cfe-dev <[hidden email]> wrote:

Hello Clang-Experts,

 

I’m using Clang-CL in Visual Studio – everything is working fine! Hooray!

But recently I noticed that some header files related to the C-Library are duplicated on my hard drive. For example: stddef.h – so I searched for it and noticed, that Visual Studio has like… 5 of them, but all related to different versions of MSVC. That made sense to me, but then: surprise! I also have that file under “C:\Program Files\LLVM9\lib\clang\9.0.0\include” being obviously related to Clang. I also noticed that there are many files duplicated between Clang and MSVC.

 

Now I wonder… If I run Clang-CL, should I use the most up to date MSVC header or the Clang one?

Why are these files duplicated anyway?

 

I feel like, that this is a silly question, but I seriously have no idea.

 

Kind greetings

Björn

Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Heiko Lampert, Takashi Nagano, Takeshi Fukushima. Junichi Tajika
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Duplicated header between Clang and MSVC - why?

Renato Golin via cfe-dev
On Tue, Oct 1, 2019 at 11:58 PM Gaier, Bjoern via cfe-dev <[hidden email]> wrote:

Hello Clang-Experts,

 

I’m using Clang-CL in Visual Studio – everything is working fine! Hooray!


Glad to hear it! :)
 

Now I wonder… If I run Clang-CL, should I use the most up to date MSVC header or the Clang one?


If you use clang-cl, it should automatically use some combination of both sets of headers. You can see in vadefs.h, for example, `#include_next` is used like so:
#include_next <vadefs.h>
So both clang and MSVC's vadefs.h header is used.
 

Why are these files duplicated anyway?


What David said is correct. The headers that clang ships tend to define things that are tightly coupled to the compiler. See the way clang implements the intel intrinsics, for example, by looking at the mmintrin.h header.

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Duplicated header between Clang and MSVC - why?

Renato Golin via cfe-dev

Thank you David and Reid!

 

The background for this question is, that I we have a tool that creates C code – then it runs Clang-Cl as an external tool to create object files. The user however will not have a full C/C++ development environment so we planed on only “shipping” the needed header files. For some tests I used all Visual Studio headers and everything compiled fine – I simply added all paths with -I

 

So if I have a ‘duplicated’ header, would it be better to use the Clang header? Or should I include both header in the search path?

 

Kind greetings and thank you again

Björn

 

From: Reid Kleckner <[hidden email]>
Sent: 03 October 2019 23:27
To: David Blaikie <[hidden email]>
Cc: Gaier, Bjoern <[hidden email]>; [hidden email]
Subject: Re: [cfe-dev] Duplicated header between Clang and MSVC - why?

 

On Tue, Oct 1, 2019 at 11:58 PM Gaier, Bjoern via cfe-dev <[hidden email]> wrote:

Hello Clang-Experts,

 

I’m using Clang-CL in Visual Studio – everything is working fine! Hooray!

 

Glad to hear it! :)

 

Now I wonder… If I run Clang-CL, should I use the most up to date MSVC header or the Clang one?

 

If you use clang-cl, it should automatically use some combination of both sets of headers. You can see in vadefs.h, for example, `#include_next` is used like so:

#include_next <vadefs.h>

So both clang and MSVC's vadefs.h header is used.

 

Why are these files duplicated anyway?

 

What David said is correct. The headers that clang ships tend to define things that are tightly coupled to the compiler. See the way clang implements the intel intrinsics, for example, by looking at the mmintrin.h header.

Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Heiko Lampert, Takashi Nagano, Takeshi Fukushima. Junichi Tajika
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Duplicated header between Clang and MSVC - why?

Renato Golin via cfe-dev
On Sun, Oct 6, 2019 at 11:48 PM Gaier, Bjoern <[hidden email]> wrote:

So if I have a ‘duplicated’ header, would it be better to use the Clang header? Or should I include both header in the search path?


I think in the end because of the usage of `include_next` it will be necessary to have two directories of headers:
- clang's headers
- msvc's headers
The search path has to put clang's first and MSVC's second. In this context, the organization could be up to you. 

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev