[comp.sys.amiga] lattice C NOVICE question

dsn@elctr.UUCP (Dan Soeren Nielsen) (03/18/91)

Hi there, can someone help me with some beginners problems.

 I'm quit new to programming in C, but after a short course at my company 
(using Turbo C on PC) I thought I was ready to start with some basic 
examples on a Amiga (using Lattice Ver 5.0). 
 I started out by typing in the first example in "Amiga bogen", the danish
version of "Programmer's guide to the Amiga" by Robert A.Peck. You will 
see the program below:

#include "libraries/dosextens.h"
extern struct FileHandle *Open();

main()
{
      struct FileHandle *dos_fh;
      if (dos_fh = Open("*",MODE_OLDFILE))
      {
            fprintf(dos_fh,"%ls","Hello there!\n");
            Close(dos_fh);

      }
      else
      printf("Error!!\n");

}

 I'v checked it for typing errors several times, but I still end up at 
the Guru. It seems that the "fprinf" can't be used together with "Open" 
and "Write" should be used instead.
 Is this an error in the book or is the problem due to incompatibility 
with the Lattice compiler?
 
 By the way; Where do I find a description of the functions in dosextens


I'll be greatfull if somebody could help me out.

Klaus
---
If this posting contains opinions, they are my own and not that of my
employer.


E-mail address : kv@elctr.dk

ewhac@well.sf.ca.us (Leo 'Bols Ewhac' Schwab) (03/20/91)

In article <732@elctr.UUCP> dsn@elctr.UUCP (Dan Soeren Nielsen) writes:
>#include "libraries/dosextens.h"

	This should be:

#include <libraries/dosextens.h>

>extern struct FileHandle *Open();
>
	That will work, but technically, it should be:

extern BPTR	Open();

>      if (dos_fh = Open("*",MODE_OLDFILE))
>      {
>            fprintf(dos_fh,"%ls","Hello there!\n");

	This will kill you if you linked with Lattice's lc.lib.  The
particular version of fprintf() being used in this example is found in
amiga.lib, so to make this work, don't specify lc.lib during the link stage.

	If you want to use Lattice's fprintf(), then you should use fopen()
instead of Open().

_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
Leo L. Schwab -- The Guy in The Cape	INET: well!ewhac@ucbvax.Berkeley.EDU
 \_ -_		Recumbent Bikes:	UUCP: pacbell > !{well,unicom}!ewhac
O----^o	      The Only Way To Fly.	      hplabs / (pronounced "AE-wack")
				Silent Software
    Moving ahead at the speed of light, because we are infinitely massive.

varney@cbnewsd.att.com (Al Varney) (03/23/91)

In article <23702@well.sf.ca.us> ewhac@well.UUCP (Leo 'Bols Ewhac' Schwab) writes:
    [some concise information]

> Leo L. Schwab -- The Guy in The Cape	INET: well!ewhac@ucbvax.Berkeley.EDU
>  \_ -_	Recumbent Bikes:	UUCP: pacbell > !{well,unicom}!ewhac
> O----^o      The Only Way To Fly.	      hplabs / (pronounced "AE-wack")
> 			Silent Software
>  Moving ahead at the speed of light, because we are infinitely massive.

    HE'S   BAAAACK !!!    LEO SPEAKS !!!    LONG LIVE THE CAPED ONE .....

Hi Leo, how's it going, eh?

   Al Varney     AT&T    

Petri.Pusa@p2.f501.n220.z2.FIDONET.ORG (Petri Pusa) (03/24/91)

 > >#include "libraries/dosextens.h"
 > 
 >         This should be:
 > 
 > #include <libraries/dosextens.h>

What's the big difference ? I doubt that anybody has a libraries
directory including dosextens.h by a mistake in that directory where
(s)he is compiling from so that the information would get mixed up.
 
 > >extern struct FileHandle *Open();
 > >
 >         That will work, but technically, it should be:
 > 
 > extern BPTR     Open();

How about #include <proto/dos.h> ? And again that doesn't have any
effect to the program code. Perhaps it's technically right, but why not
use the header files made by Commodore which should be technically
always right ? 



--  
Petri Pusa - via FidoNet node 2:220/801
UUCP: ...!fuug!casino!501.2!Petri.Pusa
INTERNET: Petri.Pusa@p2.f501.n220.z2.FIDONET.ORG

gwharvey@lescsse.jsc.nasa.gov (Greg Harvey) (04/01/91)

In <588.27ED7F66@casino.FIDONET.ORG> Petri.Pusa@p2.f501.n220.z2.FIDONET.ORG (Petri Pusa) writes:
> > >#include "libraries/dosextens.h"
> > 
> >         This should be:
> > 
> > #include <libraries/dosextens.h>
>
>What's the big difference ? I doubt that anybody has a libraries
>directory including dosextens.h by a mistake in that directory where
>(s)he is compiling from so that the information would get mixed up.
> 
> > >extern struct FileHandle *Open();
> > >
> >         That will work, but technically, it should be:
> > 
> > extern BPTR     Open();

>How about #include <proto/dos.h> ? And again that doesn't have any
>effect to the program code. Perhaps it's technically right, but why not
>use the header files made by Commodore which should be technically
>always right ? 

I know this has been discussed before, so I'm following up with a reminder.
SAS/Lattice C's lclib redefines several Amiga DOS library routines.  If you
use lclib, you "preempt" the Amiga DOS library routines.  This means
you SHOULD use lattice includes when doing ANSI-compatible programming.

Another reason is that SAS/Lattice handles library calls in a specific,
optimized, NON-ANSI fashion if the SAS/Lattice prototypes are used and the
proper compile options are used.


--
If you get the impression I'm not qualified to speak for my company, it's
because I ain't, I can't, I don't, I won't, and I don'wanna.
Greg Harvey                    --Temporarily without mail service
Lockheed, Houston Texas        --Hope to have a PSCNI route soon!