[LLVMdev] Opaque type usage to represent foreign types

Eli Friedman eli.friedman at gmail.com
Sun May 18 11:55:46 PDT 2008


On Sun, May 18, 2008 at 11:24 AM, Robert Zeh <robert.a.zeh at gmail.com> wrote:
> In my project I have a group of foreign types (C++ classes) that I
> want to use, but don't want to represent as structs within LLVM.  For
> example, for each field in each C++ class I have a setter and getter
> function that I'd like to use.  The setters and getters are "extern C"
> functions to avoid problems with C++'s name mangling.
>
> After going over the documentation it seems like I can do this by
> creating a unique opaque type for each C++ class to track types during
> my compilation, and then resolving all of the opaque types to void*
>
> Is this a reasonable approach?

Yes, looks reasonable, except that you don't need to resolve the
types; it's perfectly legal to leave a type as opaque.

-Eli



More information about the llvm-dev mailing list