[code] #if TargetWin32
dim libLocation as Strig = “SLABHIDtoUART.dll” #else
dim libLocation as String = app.ExecutableFile.parent.parent.child(“Resources”).child(“libSLABHIDtoUART.dylib”).absolutePath #endif
Declare Function HidUart_GetNumDevices Lib libLocation (byref numDevices as uint32, vid as uint16, pid as uint16) as Integer
[/code]
On the declare line, the compiler is complaining: “A constant was expected here, but this is some other kind of expression.”, and highlights the “libLocation” parameter.
The documentation for Declare specifies that the library is a string, but can optionally be a constant.
@Eli Ott - I understand that they are not constants, but my reading of the documentation for Declare indicates that it will accept a String there, and that it does not have to be constant - only that it may be.
When it says it is a string, it means a string literal. (“This is a string literal”) not a string variable.
I don’t remember for sure, but there is some magic you can use with something similar to
const libLocation = "@executable_path/../LIBNAME.dylib"
as the constant which will be properly determined by the compiler if you are including it in your application bundle. I think there is a conversation here about it somewhere…
I think that if a string needs to be a constant, then the docs should reflect that. There is no differentiation between a String Literal or a String Variable.
[quote=164700:@Kimball Larsen] dim libLocation as String = app.ExecutableFile.parent.parent.child(“Resources”).child(“libSLABHIDtoUART.dylib”).absolutePath #endif[/quote]
One other thing, don’t put executable code in the “Resources” folder, make sure executable code only goes in “Frameworks”, “Plugins”, “Helpers” or “MacOS”. Code Signing v2 may fail otherwise.
[quote=164700:@Kimball Larsen]H
The documentation for Declare specifies that the library is a string, but can optionally be a constant.
[/quote]
The docs should say a STRING LITERAL or a STRING CONSTANT
Definitely not a string variable
[quote=164720:@Kimball Larsen]I think that if a string needs to be a constant, then the docs should reflect that. There is no differentiation between a String Literal or a String Variable.
[/quote]
Sure there is
Ones a LITERAL ones a VARIABLE and the compiler knows the difference
Docs fixed as it must be a string literal or string constant
I’m implementing with CP210x driver in Mac OSX (https://www.silabs.com/products/mcu/Pages/USBtoUARTBridgeVCPDrivers.aspx). I create app in mac osx and I need connect with devices via BLE, but my old mac don’t have BLE. So, I have CP210x device and I will control it via USB (UART). I see CP210x that have libSLABHIDtoUART.dylib version 2.0, and its API. But, I don’t know how to use it. After I research, I see not enough document for me, and I don’t have any example. I need help