I have written a function in C++, making a DLL:
functions.h:
#ifndef FUNCTIONS_H
#define FUNCTIONS_H
int DLLsquare(int x);
#endif /* FUNCTIONS_H */
functions.cpp:
#include "functions.h"
int DLLsquare(int x){
return x*x;
}
I compiled this to a DLL. Now I would like to import this into Pascal Script:
program TestDLL;
function Square(x: Integer): Integer;
external 'DLLsquare@libTestDLL.dll';
begin
end.
Now this doesn't compile. I get:
(7:1): Semicolon (';') expected at line 6
Compiling failed.
Several tutorials on the internet tell me that this is exactly the way to go, so what am I missing here?
Pascal Script will throw a "semicolon expected" error if you declare an external function and don't have a handler assigned to the OnExternalProc
event.
You can implement it yourself, or you can use DllExternalProc
from the uPSC_dll unit. Consider calling RegisterDll_Compiletime
on your compiler component, which assigns the OnExternalProc
event and registers two functions for your scripts to call, UnloadDll
and DLLGetLastError
.
Although it's understandable to raise an error when the host program has provided no means of handling external functions, the specific wording of the error message is nonsense. I encourage you to file an issue with the project to get it improved.