Ignore string parameter type for external functions

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
PureGuy
Enthusiast
Enthusiast
Posts: 102
Joined: Mon Aug 30, 2010 11:51 am

Ignore string parameter type for external functions

Post by PureGuy »

Default included Win32 API accept both variable types pointers or PB's strings variables.
But it's not possible to declare imports of prototypes that way.

Code: Select all

MessageBox_(0, @"Text", @"Caption" , 0) ; works
MessageBox_(0, "Text", "Caption" , 0)   ; works

Import ""
  MessageBoxW(a,b,c,d)
EndImport

MessageBoxW(0, @"Text", @"Caption" , 0) ; works
MessageBoxW(0, "Text", "Caption" , 0)   ; seriously?
This restriction doesn't make any sense and PB should really handle this.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Ignore string parameter type for external functions

Post by ts-soft »

The MessageBox_ uses the any-type. This is only supported by UserLib/Libs!

MessageBoxW uses integer-type. This can't handle text.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
PureGuy
Enthusiast
Enthusiast
Posts: 102
Joined: Mon Aug 30, 2010 11:51 am

Re: Ignore string parameter type for external functions

Post by PureGuy »

You missing the point.
The external function does not care if PB call it string, it just get the address in both cases.

The compiler should understand that and ignore this "error" by just send the address.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Ignore string parameter type for external functions

Post by ts-soft »

This is a bad idea. This was removed from CallFunction/CallFunctioFast ... to avoid problems.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Post Reply