[LLVMdev] How to know the size of a 'long'?
Duncan Sands
baldrick at free.fr
Tue Aug 21 00:26:53 PDT 2012
Hi Paul,
> AFAIK, if I want to call an external C function from IR code, I need to use Function::Create() to create a Function whose signature matches the external C function, then call ExecutionEngine::addGlobalMapping() to "bind" the LLVM Function to the external C function (right?).
>
> Assuming that's correct, if the external C function is declared:
>
> void foo(long);
>
> how can I know whether to call Type::getInt32Ty() or Type::getInt64Ty() when creating the argument types vector that will be passed to Function::Create()? I.e., how do I know how big a C 'long' is on a given platform?
if you are willing to assume that the size of long is the same as the size of a
pointer then you can use getIntPtrType from TargetData.
Ciao, Duncan.
More information about the llvm-dev
mailing list