Author Topic: Can a 64bit O2 exe call a 32bit PB dll ?  (Read 654 times)

0 Members and 1 Guest are viewing this topic.

chrisc

  • Guest
Can a 64bit O2 exe call a 32bit PB dll ?
« on: February 20, 2018, 12:56:54 PM »
Hello all

My company is willing to use an O2 exe front end, but it needs to be able to call PB 32bits dlls.
The PB 32 bits dlls would then be converted stage by stage to O2 64bits dlls at a future date.
Can this be doable ?   

This will be the starting point to migrate from PB to O2 eventually
Thanxx

Josť Roca

  • Jr. Member
  • **
  • Posts: 87
Re: Can a 64bit O2 exe call a 32bit PB dll ?
« Reply #1 on: February 20, 2018, 01:02:47 PM »
A 64-bit executable can't call 32-bit DLLs, and a 32-bit executable can't call 64-bit DLLs.

If you need to use 32 DLLs then compile the EXE as 32 bit. If later you want to use 64 DLLs, recompile the EXE as 64 bit.

And before you ask, you can't call both 32 and 64-bit DLLs from the same executable.

chrisc

  • Guest
Re: Can a 64bit O2 exe call a 32bit PB dll ?
« Reply #2 on: February 20, 2018, 07:26:51 PM »
Thanxx Jose good to know this, as gonna need a way to circumvent 64/32 bits transfer of data

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 3751
    • Oxygen Basic
Re: Can a 64bit O2 exe call a 32bit PB dll ?
« Reply #3 on: February 21, 2018, 01:03:32 AM »

A warm welcome to Josť !

Yes, I would suggest starting with your smaller DLLs, converting to 32 bit O2, so that you can test the integrity of the new dlls one by one. Tackled individually, they will not defeat you.

Shifting to 64bit is mostly about following the rules, ensuring that handles and pointers are 64bit and that variable passed byref have matching widths (eg longs and dwords).

BTW O2 uses the same strings as PB and thinBasic (ole bstr strings)

jcfuller

  • Full Member
  • ***
  • Posts: 143
Re: Can a 64bit O2 exe call a 32bit PB dll ?
« Reply #4 on: February 21, 2018, 04:40:56 AM »

BTW O2 uses the same strings as PB and thinBasic (ole bstr strings)
Charles,
  Would you elaborate a bit on this?
Are you saying we can use the O2 string type for any and all occasions that call for a bstr?

James

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 3751
    • Oxygen Basic
Re: Can a 64bit O2 exe call a 32bit PB dll ?
« Reply #5 on: February 21, 2018, 05:54:20 AM »

Yes, based on SysAllocStringBytelen and SysFreeString.

O2 uses these calls to implement dynamic memory allocation, and garbage collection.

O2 dlls with procedures that use string param are compatible with PB.

jcfuller

  • Full Member
  • ***
  • Posts: 143
Re: Can a 64bit O2 exe call a 32bit PB dll ?
« Reply #6 on: February 24, 2018, 12:11:06 PM »
Charles,
  What is the difference between native O2 strings and bstrings?
James


Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 3751
    • Oxygen Basic
Re: Can a 64bit O2 exe call a 32bit PB dll ?
« Reply #7 on: February 24, 2018, 01:28:56 PM »
O2 strings have an additional level of indirection, which points to an entry in a garbage collector's list. Each entry contains a bstring. Similar to Zale strings, I believe :)


Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 3751
    • Oxygen Basic
Re: Can a 64bit O2 exe call a 32bit PB dll ?
« Reply #8 on: February 24, 2018, 06:26:13 PM »
When strings are passed byval in a function call, they go as bstrings, and are used by the function directly in this form.

They are also passed in this dereferenced way to functions requiring char* strings, and to unprototyped functions

jcfuller

  • Full Member
  • ***
  • Posts: 143
Re: Can a 64bit O2 exe call a 32bit PB dll ?
« Reply #9 on: February 25, 2018, 02:48:02 AM »
Charles,
  Is there a need for any string types other than O2 string and wstring?
If so what would be that scenario?

James

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 3751
    • Oxygen Basic
Re: Can a 64bit O2 exe call a 32bit PB dll ?
« Reply #10 on: February 25, 2018, 04:28:12 AM »

Yes, objects may 'prefer' to do their own garbage collection within a destructor. It's more efficient to use bstrings directly.

Also, Ported C code and most APIs use char*, so we have to support that too.

jcfuller

  • Full Member
  • ***
  • Posts: 143
Re: Can a 64bit O2 exe call a 32bit PB dll ?
« Reply #11 on: February 25, 2018, 05:44:52 AM »
Charles,
When strings are passed byval in a function call, they go as bstrings, and are used by the function directly in this form.

They are also passed in this dereferenced way to functions requiring char* strings, and to unprototyped functions


Yes, objects may 'prefer' to do their own garbage collection within a destructor. It's more efficient to use bstrings directly.

Also, Ported C code and most APIs use char*, so we have to support that too.

Could you pass an O2 string to a c++ prototype in a function that uses const char* ??
How would you prototype that in O2 parlance?

Yes I see where we need char/wchar buffers for retrieving info from c/c++ apis.

James





Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 3751
    • Oxygen Basic
Re: Can a 64bit O2 exe call a 32bit PB dll ?
« Reply #12 on: February 25, 2018, 06:09:05 AM »
Yes, char* is downwards compatible with bstring. You can use a bstring wherever a char* is expected, but notvice-versa.

A bstring has null terminators after the end of its chars, and a 32bit length field before the start of its chars.