0 votes
by Jeffrey Massung (120 points)

For example:

// c lib
struct vec2 { float x, y; };
vec2 normalized(vec2 v);

// forth
LIBRARY: c-lib.dll

BEGIN-STRUCTURE vec2
  CELL FIELD x
  CELL FIELD y
END-STRUCTURE

EXTERN: vec2 normalized( vec2 v );

The above doesn't work (as-is), obviously, but wasn't sure if there was a way to do this or not?

1 Answer

0 votes
by Stephen Pelc (4.2k points)

The 32 bit Windows ABI does not support passing structures by value. Pass pointers instead.

EXTERN: void * normalized( void * pv );

You may find yourself with an extra item on the stack. You can use the disassembler to disassemble normalized.

s" normalized" ExternLinked disasm/f

Under Windows 64 it is all different again. Linux and MacOS both use the System V ABI.

...