Workaround for #import

Hello everyone,

currently I’m converting some old visual studio projects for the use with the clang compiler. Everything was fine, until I hit the following line:

#import <file.tlb> rename(“SendMessage”, “SendMessage”) |

  • |

Clang stop the work and complained:

error : #import of type library is an unsupported Microsoft feature |

  • |

I get it - this doesn’t work, but is there no workaround or another solution for this problem?

Kind regards
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, Hiroshi Kawamura, Takashi Nagano, Takeshi Fukushima.

Hi Björn,

It’s been a decade or two since I used #import, so I could be misremembering, but here’s an idea:

#import of x.tlb generates two files: x.tlh and x.tli. They are (heavily VC-specific) C++ sources.

If you can get your VC build to generate those, and #include the tlh and compile the tli as a source file in your Clang build, I think Clang supports enough language features for it to work.

Fingers crossed,

  • Kim

Hey Kim,

your idea worked! Thank you a lot!

Kind regards
Björn