[comp.sys.mac] 4th Dimension Code Resources

hvt@tnosel.UUCP (henq) (02/03/88)

Hi, I'm asking this on behalf of a friend of mine (put your answer in a
plain brown envelope, please :-). 

He  tries to attach a custom routine to 4th dimension, writing the routine
as the main() part of a LSC program (no globals etc). When he proceeds
as described, and calls the routine a 'stack overflow' message appears.

What do we wrong ?

Thanks in advance...

-Henk


Have a nice day!

rs4u+@andrew.cmu.edu (Richard Siegel) (02/04/88)

A very possible cause is that the main() routine is not defined as "pascal".

If you're writing code resources, such as HyperCard XCMDs, window or
menu definitions, or 4th Dimension externals, the host program expects
the code resource main routine to use Pascal calling conventions..

I know nothing about 4D, but suppose it passes an int, a char, and a lonmg
to your main routine. In C, your main should be declared as follows:

pascal void main(i, c, l)
int i;
char c;
long l;

note that if the Pascal interface is to a *procedure*, that is, no return
type, you *MUST* declare your main as "pascal void". Otherwise, mayhem 
results.

Hope this helps.

		--Rich

Rich Siegel, THINK Technologies

----------------