[net.micro.amiga] Problem with Lattice C Compiler

normc@tekigm2.UUCP (Norm Church) (02/25/86)

     I am having problems with the Lattice C compiler
accepting the program that is listed below. It
compiles and executes on a Vax unix system 4.2 but gives
the following errors on my Amiga. This same problem
occurs in version 3.03 and 3.02 of the compiler.

     Can someone see any reason why it should not 
compile on my Amiga?  I would appreciate any
help on this problem.

Regards, 

Norm Church
---------------------------------------------------
Errors listed in both versions 3.02 & 3.03:

Lattice AMIGA 68000 C Compiler (Phase 1) V3.02
Copyright (C) 1984 Lattice,  Inc.)
ram:strncpy.c 32 Error 17: too many operands
ram:strncpy.c 32 Error 57: semi-colon expected

---------------------------------------------------
/* strncpy sample program */

#include <stdio.h>

main()
{

char fld[100];
char ans[100];
int len;
        strcpy(fld, "The first line to copy");

        printf("copy 5 characters\n");
        len=5;
        strncpy(ans,  fld,  len);
        printf("ans= %s\n",  ans);

        printf("copy 10 characters\n");
        len=10;
        strncpy(ans,  fld,  len);
        printf("ans= %s\n",  ans);
}
/* ================================== */
strncpy(to,  from,  len)
char *to;
char *from;
int len;
{
int n;

    for(n=1; n<=len; n++)            <--- this is line 32
       *to++ = *from++;                   that gets tagged
    *to='\0'; /* terminate string */      as an error.
} /* strncpy() */
-------------------------------------------------------------

dillon@CORY.BERKELEY.EDU (Matt Dillon) (02/26/86)

	I can't see anything right off.  If it works with the vax compiler,
then I would guess lattice's stdio.h defined some macro somewhere which you
are inadvertently using as a variable (and it doing a macro expansion on it).
At least, that is all I can think of.

	Lattice 3.03 has strncpy anyway.  Also, if your intending to make
yours compatible with Lattice's/UNIX, then you should check for source
termination before 'n' is reached.

	QUESTION TO AMIGA PEOPLE: Just how fast are ports, send and rec.
message?  What is the overhead?

					-Matt

bruceb@amiga.UUCP (Bruce Barrett) (02/26/86)

In article <471@tekigm2.UUCP> normc@tekigm2.UUCP (Norm Church) writes:
>
>
>     I am having problems with the Lattice C compiler ...
>the following errors on my Amiga. This same problem
>occurs in version 3.03 and 3.02 of the compiler.
	:
>Norm Church

Norm,  This is one of the nicest bug reports I've received.  Very
spacific, very complete.  Thank you.  ((but I can't reproduce the problem))
>---------------------------------------------------
>Errors listed in both versions 3.02 & 3.03:
>
>Lattice AMIGA 68000 C Compiler (Phase 1) V3.02
>Copyright (C) 1984 Lattice,  Inc.)
>ram:strncpy.c 32 Error 17: too many operands
>ram:strncpy.c 32 Error 57: semi-colon expected

I downloaded this file, removed everything upto and past the "------------"s,
removes the "<--- error here" comments end compiled it with my V3.03 Lattice.
(Native, on the amiga.)  This is the output I got:
	Lattice AMIGA 68000 C Compiler (Phase 1) V3.03
	Copyright (C) 1984 Lattice, Inc.
	Lattice AMIGA 68000 C Compiler (Phase 2) V3.03
	Copyright (C) 1984 Lattice, Inc.
	
	copy 5 characters
	ans= The f
	copy 10 characters
	ans= The first 

No problem here.  My CLI stack size is 4000 bytes, I'm running V1.1 kickstart
and C-CLI.  The sizes of my compiler passes are: LC1=108528 LC2=113228.
I'm using a slightly modified version of Makesimple.

Did you get your 3.03 from Lattice of Commodore?

--Bruce Barrett