DllImport for C function with var args

L

Leon

Hi,

I have a C exported function in a DLL that has the following proto-type:
int _cdecl MyFunction( LPCSTR fmt, ... );

Does anyone know the DllImport declaration for this so that I can call this
in C#?

Thanks.

Leon
 
L

Leon

I know about using param in C#. But can you read my question carefully?

How to you declare [DllImport(....)] in C# for a C function that takes var
args like:

int _cdecl DoSomething( int abc, ... );

Thanks.

Leon
 
L

Leon

Thanks.

Your answer and reference actually confirm that my declaration has not been
at fault.

Leon

Chris Jobson said:
How to you declare [DllImport(....)] in C# for a C function that takes var
args like:

int _cdecl DoSomething( int abc, ... );

You can't do a single declaration for the function. Instead you have to do a
separate declaration for each set of arguments you want to call it with. See
http://msdn.microsoft.com/en-us/lib...importattribute.callingconvention(VS.71).aspx
which has an example of how to call printf from C#.

Chris Jobson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top