wayne-c wrote: ↑Wed Jul 28, 2021 9:58 am
Code: Select all
Prototype ProtoCurlEasyPerform(handle.i)
If OpenLibrary(0, "libcurl-x64.dll")
CurlEasyPerform.ProtoCurlEasyPerform = GetFunction(0, "curl_easy_perform")
EndIf
Q: What is the scope of the procedure CurlEasyPerform()?
A: CurlEasyPerform() is not a procedure it is a prototyped
variable that has been assigned the address of a function in a dll.
Q: Is it defined globally?
A: No. The scope of 'Global' was not used in its definition. Because no explicit definition including scope was used (i.e. Global, Define, Threaded) the default scope is the same as if 'Define' was used. This means it is local to the scope in which it appears, which in this case is the main scope. Other possible local scopes include that of a procedure or a module.
Q: Is it safe to use the procedure in threads?
A: it a prototyped variable with only scope local to the main block. It is not a 'procedure' though the procedure whose address it holds can be called in a similar manner as calling other procedures. If it was a procedure its scope would be limited only by whether it was defined in a module, a module's declaration, or in the main scope outside of a module. As a prototyped variable it has additional scopes possible. . To be used in a thread It would first have to be either declared as Global in the main scope or as 'Shared' in the thread's procedure and second it should be treated as read only and not have its value changed after its initial declaration in the main scope.