[cfe-commits] [PATCH] #import directive in MS compatibility mode

J B jayblanchard.cpp at gmail.com
Wed Mar 14 20:52:40 PDT 2012

MSVC typically throws the generated .tlh (type library header) and .tli
(wrapper implementation) into the solution's defined intermediate
directory.  They aren't part of the source tree unless someone explicitly
makes them part of the source tree.

It might make sense to error on #import with information to generate the
files with MSVC and make them permanent, and switch to #includes.

I believe the attributes can be ignored unless you're going to go forward
with this auto-determined include plan.  If you do that, you'll need to pay
attention to the attributes implementation_only and no_implementation, as
they control whether there is a .tlh or .tli

Jay Blanchard

On Wed, Mar 14, 2012 at 8:31 PM, Aaron Ballman <aaron at aaronballman.com>wrote:

> On Wed, Mar 14, 2012 at 6:02 PM, Francois Pichet <pichet2000 at gmail.com>
> wrote:
> > On Wed, Mar 14, 2012 at 12:15 PM, Douglas Gregor <dgregor at apple.com>
> wrote:
> >>
> >> On Mar 12, 2012, at 4:10 PM, Aaron Ballman wrote:
> >>
> >>> MSVC uses the #import directive in a far different way than the
> >>> language extension clang supports.  Instead of including the target
> >>> into the source, it parses a type library and generates C++ classes
> >>> from the definitions.  This difference in behavior is large enough
> >>> that we should be warning users in MS compatibility mode so they can
> >>> understand what's happening.
> >>>
> >>> This patch addresses PR 10727.
> >>
> >>
> >> Given that the subject of an MSVC-style #import is likely to be a
> binary file, I think it would be better to simply warn that we are ignoring
> the #import directly entirely, rather than going through
> HandleIncludeDirective. Also, can you perhaps make
> >
> > Actually, MSVC #import will generate 2 header files from the typelib
> > and then include them. I think generating *.h from COM typelib is
> > outside the scope of clang but we could somehow assume that the .h are
> > already pregenerated and try to include them.
> >
> > That would make it possible to compile a COM project with clang if the
> > project has already been compiled with MSVC first. (to get the .h
> > generated).
> Just so I can be sure I follow what you mean:
> When we see #import in MS mode, instead of importing the file
> specified (which is likely to be binary), we should attempt to import
> the primary header file (the TLH) which would have been generated by
> MSVC if it's available?
> What about all the attribute jazz?  We're not currently parsing that;
> should we have a separate patch to parse and ignore it?
> ~Aaron
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120314/deb55a67/attachment.html>

More information about the cfe-commits mailing list