[comp.sys.amiga.tech] Help with useing SAS C5.10 to make Libraries

slmt9@cc.usu.edu (01/10/91)

	Hello to all the netters out there.
	
	As is usual when I post it is to ask a question. 

	The question this time is to find out how to get SAS C V5.10 to compile
a library. The manual says that it can be done but then gives almost no
information on how to do it. I have tried several time but get hung up on a
few area's so it is time to try to get some help.

	First of what does the declaration of the function itself have to look
like. I read in the source File that it has to be __saveds so my code looks
like this
   
ULONG __saveds Add(a,b)
 ULONG a,b;
{
  return (a+b);
}

If there are any corrections that need to be made here please let me know.

	Question number two. What does the .FD file need to look like. When I
compile I get asked what the name of the library is? When I try to type
something simple like MyLibrary then it tells me "error -- 'MyLibrary' is not a
defined symbol" so where deos it get the name and other info from. Does this
stuff go in the .FD file. Is there a different way to enter it?

	Any and all help would greatly be appriciated.

	Thanks,
	Joshua
	SLMT9@cc.usu.edu

dej@qpoint.amiga.ocunix.on.ca (David Jones) (01/29/91)

>In article <1991Jan9.104606.46575@cc.usu.edu> slmt9@cc.usu.edu writes:
>	First of what does the declaration of the function itself have to look
>like. I read in the source File that it has to be __saveds so my code looks
>like this
>   
>ULONG __saveds Add(a,b)

>If there are any corrections that need to be made here please let me know.

If you want your function to take parameters in registers (most Amiga
library functions do), then you'll need to use __asm and register commands
like this:

ULONG __saveds __asm Add(register __d0 int a, register __d1 int b)

Tips:

The register name must be in lowercase.  It must be prefixed by two
underscores.

You also need the type of each argument.

When you compile, you need to use -ml on the command line.

If your library calls routines which are in its function table (most libraries
do), then don't use #pragmas for functions in your library.  Instead, use
prototypes formatted just like the function definitions.  You may continue
to use pragmas for functions in other libraries.

With reference to a message that Peter Cherna sent to me about a month ago,
do not perform any library initialization in the file "libinit.c"


>	Question number two. What does the .FD file need to look like. When I
>compile I get asked what the name of the library is? When I try to type
>something simple like MyLibrary then it tells me "error -- 'MyLibrary' is not a
>defined symbol" so where deos it get the name and other info from. Does this
>stuff go in the .FD file. Is there a different way to enter it?

Go into your .fd file and check out the name of the base.  If there is no
underscore on the base name, add one.

##base FlowBase		WRONG
##base _FlowBase	BETTER


--



	David Jones	UUCP:	dej@qpoint.amiga.ocunix.on.ca
			Fido:	1:163/109.8