|
Home
News
Profile
Contact
Half-Life
Music
PCASTL
Computer Science
Videos
Readings
OpenGL
Elements
C64 sids
Links
|
|
Operators
Data Types
Internal Functions
Tree Structure
Batch Execution
Examples
Interpreter
|
|
Library Example In a file named main.c: #include <math.h>
#include <string.h>
typedef struct
{
double x;
double y;
} point;
typedef struct
{
point vertices[3];
double perimeter;
float extra;
} triangle;
double distance(point a, point b)
{
return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}
int so_demo(int n1, int n2, float copy, triangle* t,
double* avgx, double* avgy, char* str)
{
t->perimeter = 0.0;
t->perimeter += distance(t->vertices[0], t->vertices[1]);
t->perimeter += distance(t->vertices[1], t->vertices[2]);
t->perimeter += distance(t->vertices[2], t->vertices[0]);
t->extra = copy;
*avgx = (t->vertices[0].x + t->vertices[1].x + t->vertices[2].x) / 3.0;
*avgy = (t->vertices[0].y + t->vertices[1].y + t->vertices[2].y) / 3.0;
strcpy(str, "done");
return n1 + n2;
}
On the command line: gcc -fPIC -c main.c ld -shared -soname exlib.so -o exlib.so -lc main.o In the interpreter: test_dll_demo.astl. Calls to a function in a library return a PCASTL object with always the following members.
|
|
Mobile
|