9 messages in net.java.dev.jna.usersRE: [jna-users] C++ StdCallFunctionMa...
FromSent OnAttachments
Ewan SlaterApr 8, 2008 10:45 am 
Timothy WallApr 8, 2008 11:15 am 
Paul MooreApr 8, 2008 11:50 am 
Albert StrasheimApr 8, 2008 1:26 pm 
Ewan SlaterApr 9, 2008 12:44 am 
Timothy WallApr 9, 2008 3:53 am 
Ewan SlaterApr 9, 2008 11:44 am 
Timothy WallApr 9, 2008 7:32 pm 
Timothy WallApr 9, 2008 7:32 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:RE: [jna-users] C++ StdCallFunctionMapperActions...
From:Paul Moore (paul@centrify.com)
Date:Apr 8, 2008 11:50:58 am
List:net.java.dev.jna.users

if they are plain functions (as opposed to class methods) you can put extern "C" in front of the fucntion declarations inthe c++ code and that will turn the name mangling off

-----Original Message----- From: Timothy Wall [mailto:twal@dev.java.net] Sent: Tuesday, April 08, 2008 11:16 AM To: use@jna.dev.java.net Subject: Re: [jna-users] C++ StdCallFunctionMapper

You'd at least need a name mangler for MS VC++. I tinkered with writing one for GCC, which at least has documented mangling. I don't think MSVC is officially documented (although some other compilers can produce compatible output).

Depending on what else you do, you'd also need to auto-insert your C++ object as a first argument, potentially read/vector into the virtual function table, and auto-convert into C++ types (std::string being rather common).

If your C++ functions are all statics (non-object methods) and only use C types, then you only have to worry about the name mangling.

There are a number of projects out there that *might* provide easier C+ + linkage, but most involve boilerplate and code generation, in addition to some native compilation. See the OTHERS file in JNA's SVN repo for a list of related projects.

On Apr 8, 2008, at 1:46 PM, Ewan Slater wrote:

Hi,

I've just satrted using JNA, and it's working (hooray), but...

My DLL is written in C++ not C, and when I try to use the StdCallFunctionMapper it doesn't find my functions in the DLL (boo! hiss!).

Has anyone got a StdCallFunctionMapper for C++ that they could be kind

enough to send me / point me to?

I'm compiling the DLL in Microsoft VC++, and using the __stdcall calling convention (but would happily switch to another if that's what

it took).

Cheers,

Ewan