Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Function overloading in third party commands

Author
Message
Klukk2
22
Years of Service
User Offline
Joined: 29th Oct 2003
Location:
Posted: 29th Oct 2003 18:46
Greetings and salutations.

Quick question: Does the third party command interface in dbpro support function overloading?

Example:

(c++ code in a dll)



(Stringtable in dll)
STRINGTABLE


Would the dbpro compiler be able to ?differentiate? between the two commands based on the input parameters?

I would simply test this and see if it works, but I'm writing my dll using the free C++ command line tools from Borland so it would take me some time to try this out.

Any takers?
Kevin Picone
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 29th Oct 2003 18:52
Quote: "
Would the dbpro compiler be able to ?differentiate? between the two commands based on the input parameters?

"


nope.

Kevin Picone
Play Basic - Visible Worlds - Kyruss II
[url]www.underwaredesign.com[/url]
Kentaree
23
Years of Service
User Offline
Joined: 5th Oct 2002
Location: Clonmel, Ireland
Posted: 29th Oct 2003 18:53 Edited at: 29th Oct 2003 18:57
My guess is it will (or should) be able to support it, as it also has internal commands that can be used with different (optional) parameters.
I'll try it out, and if nobody else has answered this, I'll tell you for sure

[EDIT]: Posted while I was typing UW . You seem to be a lot more
certain than me, but how does DBP differentiate between its
own commands in that case?

I would be unstoppable if I could just get started...
Klukk2
22
Years of Service
User Offline
Joined: 29th Oct 2003
Location:
Posted: 29th Oct 2003 18:58
Thanks Kentaree, you're a sport
empty
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 29th Oct 2003 19:11 Edited at: 29th Oct 2003 19:12
Quote: "nope."

Short and precise.

There's work-around:
Just don't overload the C functions and it might work.

I awoke in a fever. The bedclothes were all soaked in sweat.
She said "You've been having a nightmare and it's not over yet"
OSX Using Happy Dude
22
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 29th Oct 2003 19:32
You can - sort of:

Say you want to write 4 different versions of a print command, which prints an integer, byte, word and long. What you would do is :

A) Write 4 different C functions (giving them slightly different names)
B) Set up 4 string tables, each of which has the same command (but different parameters), plus the mangled C function name.

Its how myself and other people write functions that keep the same name but different parameters.


Avatar & Logo by Indi. Insert witty comment here...
Klukk2
22
Years of Service
User Offline
Joined: 29th Oct 2003
Location:
Posted: 29th Oct 2003 19:35
TCA: Great, that's what I wanted to hear.

Well, off to the coding arena to finish my dll.

if nothing sticks to teflon, then how do they make teflon stick to the pan?
empty
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 29th Oct 2003 19:37
Like I said, "just don't overload the C functions."

I awoke in a fever. The bedclothes were all soaked in sweat.
She said "You've been having a nightmare and it's not over yet"
OSX Using Happy Dude
22
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 29th Oct 2003 20:14
Indeed


Avatar & Logo by Indi. Insert witty comment here...
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 30th Oct 2003 00:33
For an extreme example of overloading you can check out the source for the utility plug-in - there's a MIN and MAX function for every type.

You don't need to give them different names in the code if you are using C++ (mangling will effectively give them different names for you) but it's damned hard to figure out which is which if you don't
swdave
23
Years of Service
User Offline
Joined: 6th Oct 2002
Location: United States
Posted: 30th Oct 2003 04:50
Yes it can work. Compile as cpp and dont declare as "C" functons

extern "C" {
}

You can see DBP commands use this method.

DBProSystemDebug.dll

CallDLL@@YAKHK@Z
CallDLL@@YAKHKK@Z
CallDLL@@YAKHKKK@Z
CallDLL@@YAKHKKKK@Z
CallDLL@@YAKHKKKKK@Z
CallDLL@@YAKHKKKKKK@Z
CallDLL@@YAKHKKKKKKK@Z
CallDLL@@YAKHKKKKKKKK@Z
CallDLL@@YAKHKKKKKKKKK@Z
CallDLL@@YAKHKKKKKKKKKK@Z

Login to post a reply

Server time is: 2026-07-26 13:02:06
Your offset time is: 2026-07-26 13:02:06