Go Back   RunUO - Ultima Online Emulation > Developer's Corner > Programming > C/C++

C/C++ C/C++ Discussion

Reply
 
Thread Tools Display Modes
Old 10-20-2006, 06:15 AM   #1 (permalink)
Forum Expert
 
Join Date: Jan 2004
Location: England
Age: 20
Posts: 442
Default Using dllexport on a function with the __clrcall convention

Hi there, I'm pretty new to using C++ after using C# for a while now and so the syntax and that is pretty similar...
Anyway what I am trying to do is make a DLL in C++ that will interact with the Ultima.dll. I want to do this because I am writing a form that runs from within the runuo server and so it is impossible to add Ultima.dll as a reference and Ultima.dll doesn't export it's functions so I can't use dllimport in my C# code of my form. So basically I'm writing my C++ DLL that has a reference to Ultima.dll in it and then I am writing functions in my C++ dll to export bitmaps created using the functions from Ultima.dll.
However I'm having a problem with exporting my functions from my C++ dll because of the following error:
Code:
error C3395: 'UltimaHelper::Gumps::GetGump' : __declspec(dllexport) cannot be applied to a function with the __clrcall calling convention
Here is my UltimaHelper.dll code in C++:
Code:
#pragma once
using namespace System;
using namespace Ultima;

namespace UltimaHelper 
{
    public class __declspec(dllexport) Gumps
    {
        public: static System::Drawing::Bitmap^  GetGump(int index)
        {
            System::Drawing::Bitmap^ returnImage = Ultima::Gumps::GetGump(index);
            return returnImage;
        }

    };
}
Thanks for any help
__________________
David's Sig is my Sig. He always says it best.
tobyjug is offline   Reply With Quote
Old 10-20-2006, 06:35 AM   #2 (permalink)
Forum Expert
 
arul's Avatar
 
Join Date: Jan 2005
Location: Hic sunt leones ...
Age: 21
Posts: 1,278
Send a message via MSN to arul
Default

C++ projects compiled with /clr parameter are compiled into IL, and thus you can use them within your managed project with no problem.

__declspec may be used only if you compile into native code, which can be achieved through some #pragma macro.
__________________
Angels are falling the very last time, down they're burning in hate and decline, unfaithful and violent we're breaking the spell, we're god, we're scissor, in heaven and hell!
arul is offline   Reply With Quote
Old 10-20-2006, 07:38 AM   #3 (permalink)
Forum Expert
 
Join Date: Jan 2004
Location: England
Age: 20
Posts: 442
Default

Ok, so if you dont mind me asking some further questions...
What is a Pragma macro? What would one look like for me to be able to export my function?
__________________
David's Sig is my Sig. He always says it best.
tobyjug is offline   Reply With Quote
Old 10-20-2006, 08:13 AM   #4 (permalink)
Forum Expert
 
arul's Avatar
 
Join Date: Jan 2005
Location: Hic sunt leones ...
Age: 21
Posts: 1,278
Send a message via MSN to arul
Default

There's a nice article about it over at CodeProject.

http://www.codeproject.com/dotnet/managed_unmanaged.asp
__________________
Angels are falling the very last time, down they're burning in hate and decline, unfaithful and violent we're breaking the spell, we're god, we're scissor, in heaven and hell!
arul is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5