[Done] Import external variable

Post bugreports for the Mac OSX version here
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3870
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

[Done] Import external variable

Post by wilbert »

This doesn't work

Code: Select all

ImportC ""
  NSAppKitVersionNumber.d
EndImport

Debug NSAppKitVersionNumber
Windows (x64)
Raspberry Pi OS (Arm64)
nsstudios
Enthusiast
Enthusiast
Posts: 274
Joined: Wed Aug 28, 2019 1:01 pm
Location: Serbia
Contact:

Re: Import external variable

Post by nsstudios »

Did you ever figure this out? I've been wanting to import things like RAND_MAX, but seems like it's still not a thing. :(
User avatar
mk-soft
Always Here
Always Here
Posts: 5335
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Import external variable

Post by mk-soft »

I don't know that's right result

Code: Select all

ImportC ""
  dlsym(handle, symbol.p-utf8)
EndImport

Global *NSAppKitVersionNumber.Double = dlsym(-2, "NSAppKitVersionNumber")

Debug *NSAppKitVersionNumber

If *NSAppKitVersionNumber
  Debug *NSAppKitVersionNumber\d
EndIf
macOS Big Sur 11.1
Version = 2022.2000000000000454747350886
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3870
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: Import external variable

Post by wilbert »

I think RAND_MAX is a compiler macro and not a symbol you can import.
Windows (x64)
Raspberry Pi OS (Arm64)
User avatar
Shardik
Addict
Addict
Posts: 1989
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: Import external variable

Post by Shardik »

mk-soft wrote: Mon Apr 26, 2021 5:30 pm I don't know that's right result
The result is correct. The first rounded digit after the decimal point of the double value correlates with the MacOS minor version. You should output the double value of the NSAppKit version with

Code: Select all

  MessageRequester("NSAppKit version",  StrD(*NSAppKitVersionNumber\d, 1))
These are my results:
  • MacOS 11.3.1 'Big Sur': 2022.44
  • MacOS 11.2.3 'Big Sur': 2022.3
  • MacOS 10.15.7 'Catalina': 1894.6
  • MacOS 10.14.6 'Mojave': 1671.6
  • MacOS 10.13.6 'High Sierra': 1561.6
  • MacOS 10.12.6 'Sierra': 1504.8
  • MacOS 10.11.6 'El Capitan': 1404.5
  • MacOS 10.10.5 'Yosemite': 1348.2
  • MacOS 10.9.5 'Mavericks': 1265.2
  • MacOS 10.8.5 'Mountain Lion': 1187.4
  • MacOS 10.7.5 'Lion': 1138.5
  • MacOS 10.6.8 'Snow Leopard': 1038.36
Last edited by Shardik on Tue May 04, 2021 4:16 pm, edited 2 times in total.
User avatar
Keya
Addict
Addict
Posts: 1891
Joined: Thu Jun 04, 2015 7:10 am

Re: Import external variable

Post by Keya »

The first rounded digit after the decimal point of the double value correlates with the MacOS minor version
That doesn't match with one of your OS tests of "MacOS 10.15.7 'Catalina': 1894.6" ?
User avatar
mk-soft
Always Here
Always Here
Posts: 5335
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Import external variable

Post by mk-soft »

I think two decimals ...

The constants for dlsym are already defined ;)

Code: Select all

ImportC ""
  dlsym(handle, symbol.p-utf8)
EndImport

Global *NSAppKitVersionNumber.Double = dlsym(#RTLD_DEFAULT, "NSAppKitVersionNumber")

If *NSAppKitVersionNumber
  Debug "NSAppKitVersion: " + StrD(*NSAppKitVersionNumber\d,2)
EndIf
Last edited by mk-soft on Mon Apr 26, 2021 9:50 pm, edited 1 time in total.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
Shardik
Addict
Addict
Posts: 1989
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: Import external variable

Post by Shardik »

Keya wrote: Mon Apr 26, 2021 9:36 pm That doesn't match with one of your OS tests of "MacOS 10.15.7 'Catalina': 1894.6" ?
You are right. It only matches roughly. You may take a look into NSApplication.h where lots of different AppKit version constants are defined (I am currently on Mojave):
NSApplication.h wrote:typedef double NSAppKitVersion NS_TYPED_EXTENSIBLE_ENUM;
/* The version of the AppKit framework */
APPKIT_EXTERN const NSAppKitVersion NSAppKitVersionNumber;
static const NSAppKitVersion NSAppKitVersionNumber10_0 = 577;
static const NSAppKitVersion NSAppKitVersionNumber10_1 = 620;
static const NSAppKitVersion NSAppKitVersionNumber10_2 = 663;
static const NSAppKitVersion NSAppKitVersionNumber10_2_3 = 663.6;
static const NSAppKitVersion NSAppKitVersionNumber10_3 = 743;
static const NSAppKitVersion NSAppKitVersionNumber10_3_2 = 743.14;
static const NSAppKitVersion NSAppKitVersionNumber10_3_3 = 743.2;
static const NSAppKitVersion NSAppKitVersionNumber10_3_5 = 743.24;
static const NSAppKitVersion NSAppKitVersionNumber10_3_7 = 743.33;
static const NSAppKitVersion NSAppKitVersionNumber10_3_9 = 743.36;
static const NSAppKitVersion NSAppKitVersionNumber10_4 = 824;
static const NSAppKitVersion NSAppKitVersionNumber10_4_1 = 824.1;
static const NSAppKitVersion NSAppKitVersionNumber10_4_3 = 824.23;
static const NSAppKitVersion NSAppKitVersionNumber10_4_4 = 824.33;
static const NSAppKitVersion NSAppKitVersionNumber10_4_7 = 824.41;
static const NSAppKitVersion NSAppKitVersionNumber10_5 = 949;
static const NSAppKitVersion NSAppKitVersionNumber10_5_2 = 949.27;
static const NSAppKitVersion NSAppKitVersionNumber10_5_3 = 949.33;
static const NSAppKitVersion NSAppKitVersionNumber10_6 = 1038;
static const NSAppKitVersion NSAppKitVersionNumber10_7 = 1138;
static const NSAppKitVersion NSAppKitVersionNumber10_7_2 = 1138.23;
static const NSAppKitVersion NSAppKitVersionNumber10_7_3 = 1138.32;
static const NSAppKitVersion NSAppKitVersionNumber10_7_4 = 1138.47;
static const NSAppKitVersion NSAppKitVersionNumber10_8 = 1187;
static const NSAppKitVersion NSAppKitVersionNumber10_9 = 1265;
static const NSAppKitVersion NSAppKitVersionNumber10_10 = 1343;
static const NSAppKitVersion NSAppKitVersionNumber10_10_2 = 1344;
static const NSAppKitVersion NSAppKitVersionNumber10_10_3 = 1347;
static const NSAppKitVersion NSAppKitVersionNumber10_10_4 = 1348;
static const NSAppKitVersion NSAppKitVersionNumber10_10_5 = 1348;
static const NSAppKitVersion NSAppKitVersionNumber10_10_Max = 1349;
static const NSAppKitVersion NSAppKitVersionNumber10_11 = 1404;
static const NSAppKitVersion NSAppKitVersionNumber10_11_1 = 1404.13;
static const NSAppKitVersion NSAppKitVersionNumber10_11_2 = 1404.34;
static const NSAppKitVersion NSAppKitVersionNumber10_11_3 = 1404.34;
static const NSAppKitVersion NSAppKitVersionNumber10_12 = 1504;
static const NSAppKitVersion NSAppKitVersionNumber10_12_1 = 1504.60;
static const NSAppKitVersion NSAppKitVersionNumber10_12_2 = 1504.76;
static const NSAppKitVersion NSAppKitVersionNumber10_13 = 1561;
static const NSAppKitVersion NSAppKitVersionNumber10_13_1 = 1561.1;
static const NSAppKitVersion NSAppKitVersionNumber10_13_2 = 1561.2;
static const NSAppKitVersion NSAppKitVersionNumber10_13_4 = 1561.4;
mk-soft wrote:I think two decimals ...
Yes, two decimals are better and sufficient according to NSApplication.h.
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3870
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: Import external variable

Post by wilbert »

mk-soft wrote: Mon Apr 26, 2021 9:45 pm The constants for dlsym are already defined ;)
dlsym itself also is :wink:

Code: Select all

Global *NSAppKitVersionNumber.Double = dlsym_(#RTLD_DEFAULT, "NSAppKitVersionNumber")
Debug StrD(*NSAppKitVersionNumber\d, 2)
Windows (x64)
Raspberry Pi OS (Arm64)
Fred
Administrator
Administrator
Posts: 16617
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Import external variable

Post by Fred »

Fixed.
Post Reply