[LLVMdev] Opaque type usage to represent foreign types

Chris Lattner sabre at nondot.org
Sun May 18 12:25:05 PDT 2008


On May 18, 2008, at 11:24 AM, Robert Zeh 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*

You can also just declare them in the IR as "i8*" which is llvm's  
equivalent to void*.  Either way works :)

-Chris



More information about the llvm-dev mailing list