[comp.sys.amiga.tech] Lattice C

jdp@killer.DALLAS.TX.US (Jim Pritchett) (11/06/88)

     Could someone please give me a short description of the following Lattice
functions (parameters, function, etc.)?

     getfnl()
     strbpl()

Also, does the Unix (tm) function system() return to the caller when the
external program is completed?


                                    Thank you,

                                               Jim Pritchett

                                    uucp:  killer!gtmvax!dms3b1!caleb!jdp

fgd3@jc3b21.UUCP (Fabbian G. Dufoe) (11/07/88)

From article <6013@killer.DALLAS.TX.US>, by jdp@killer.DALLAS.TX.US (Jim Pritchett):
> 
>      Could someone please give me a short description of the following Lattice
> functions (parameters, function, etc.)?
> 
>      getfnl()
>      strbpl()
> 
> Also, does the Unix (tm) function system() return to the caller when the
> external program is completed?
> 
> 
>                                     Thank you,
> 
>                                                Jim Pritchett
> 
>                                     uucp:  killer!gtmvax!dms3b1!caleb!jdp

     NAME: getfnl	Get filename list
     SYNOPSIS:
	  #include <stdlib.h>
	  n = getfnl(fnp, fna, fnasize, attr);

	  int n; number of matching file names
	  char *fnp; file name pattern
	  char *fna; file name array
	  unsigned fnasize; size of file name array
	  int attr; file attribute

     DESCRIPTION
	  This function gets all file names that match the specified
	  pattern and attribute, and it places them into the file name
	  array.  Each name is stored as a null-terminated string, and the
	  file name array is terminated by a null string (i.e. a string
	  consisting of only one null byte).  If the file name pattern
	  includes a path prefix, that prefix is placed in front of each
	  matching file name.

	  The function return value is the number of strings stored in the
	  array, not including the terminating null string.
     
     -------------------------------------------------------------------
     NAME: strbpl	Build string pointer list

     SYNOPSIS
	  #include <string.h>

	  n = strbpl(s, max, t);

	  int n; number of pointers
	  char *s[]; pointer to string pointer list
	  int max; maximum number of pointers
	  char *t; text pointer

     DESCRIPTION

	  This function constructs a list of pointers to the strings
	  contained within the specified text array.  Each string must be
	  null-terminated, and the text array must be terminated by a null
	  string.  In other workds, array t must end with two null bytes,
	  one to terminate the final string and another to terminated the
	  array.  The string pointer list s is terminated by a null
	  pointer.


--Fabbian Dufoe
  350 Ling-A-Mor Terrace South
  St. Petersburg, Florida  33705
  813-823-2350

UUCP: ...codas!usfvax2!jc3b21!fgd3 
      ...uunet!pdn!jc3b21!fgd3

morgan@hcr.UUCP (Morgan Jones) (11/14/88)

In article <6013@killer.DALLAS.TX.US> jdp@killer.UUCP writes:
>Also, does the Unix (tm) function system() return to the caller when the
>external program is completed?

int
system(cmd)
	char *cmd;
{
	if (cmd == "" || cmd == NULL)
		Execute("",Input(),0L);
	else
		Execute("",0L,0L);
	return(0);
}

Though I can't remember if you have to specify output as well in either
case.  Alternatively, you may want to return -1 if Execute fails, but
you can't tell if the command failed.

>                                               Jim Pritchett



-- 
Morgan W. Jones                 morgan@hcr.uucp
HCR Corporation, Toronto, Ontario, Canada
BMATH - T minus 6 months and counting ...

michael@stb.UUCP (Michael) (12/14/88)

In article <4197@hcr.UUCP> morgan@hcr.UUCP (Morgan Jones) writes:
>In article <6013@killer.DALLAS.TX.US> jdp@killer.UUCP writes:
>>Also, does the Unix (tm) function system() return to the caller when the
>>external program is completed?
>
>int
>system(cmd)
>	char *cmd;
>{
>	if (cmd == "" || cmd == NULL)
>		Execute("",Input(),0L);
>	else
>		Execute("",0L,0L);
>	return(0);
>}

no no no.
First, system takes a cmd arg. I know the above is wrong because it isn't
even using cmd.

In answer to the question about unix, it does return when the called
program returns. So, a better approach would be

		Execute (cmd, Input(), Output());

is closer. Problems: If cmd == NULL, Execute will start a shell,
system() does nothing. If you are from Workbench, I don't think
Input() and Output() are defined (might be NULL, which is OK; might be
garbage, which is not). 

I thought I remembered another difference between system and Execute,
but I can't think of it offhand.
			Michael
: --- 
: Michael Gersten			 uunet.uu.net!stb!michael
:					crash!gryphon!denwa!stb!michael
: Coff Coff <=== Stop smoking.

tada@athena.mit.edu (Michael Zehr) (02/18/89)

Has anyone experienced the following problem with lattice C? (5.02)

variable = &foo.bar.arry[n];
printf("%d %d\n", (int) variable, (int) &foo.bar.arry[n]);

...yielding two different values!?!

i've noticed it twice in programs, and so far, it appears that if n=0,
the assignment is correct, but the evaluation in printf is wrong, and
if n=1, it's the reverse.

both times, it's been the same root structure that has had problems.  
there's no redefinition of it, no strange macros, no compilation or
linking warnings.

does anyone know of cases in which lattice C screws up structure
addresses and/or offsets?  is this why there's no option to see the 
assembly code produced by the compiler? (1/2 :-) )

what do people recommend for a C compiler?  i need one that does a 
fairly decent job of optimizing, but i'd also like it to be correct...

-michael j zehr

cmcmanis%pepper@Sun.COM (Chuck McManis) (02/18/89)

In article <9311@bloom-beacon.MIT.EDU> (Michael Zehr) writes:
>Has anyone experienced the following problem with lattice C? (5.02)
>variable = &foo.bar.arry[n];
>printf("%d %d\n", (int) variable, (int) &foo.bar.arry[n]);
>...yielding two different values!?!

It looks like a precedence problem, Lattice may incorrectly assign
"[]" and "&" the same precedence. Have you tried &(foo.bar.arry[n]) 
instead?

>does anyone know of cases in which lattice C screws up structure
>addresses and/or offsets?  is this why there's no option to see the 
>assembly code produced by the compiler? (1/2 :-) )

This is a completely bogus statement. A) Lattice has supplied OMD to
create assembly source from object modules since 3.1, B) with 5.0 you
could always pop cpr into "assembly" display mode and step through
the code.

>what do people recommend for a C compiler?  i need one that does a 
>fairly decent job of optimizing, but i'd also like it to be correct...

Was this with the -O switch that it screwed up? Or just on regular compiles.
If you really want control of your compiler port Gnu CC. 


--Chuck McManis
uucp: {anywhere}!sun!cmcmanis   BIX: cmcmanis  ARPAnet: cmcmanis@sun.com
These opinions are my own and no one elses, but you knew that didn't you.

mwm@eris.berkeley.edu (Mike (I'll think of something yet) Meyer) (03/03/89)

In article <9311@bloom-beacon.MIT.EDU> tada@athena.mit.edu (Michael Zehr) writes:
<Has anyone experienced the following problem with lattice C? (5.02)
<
<variable = &foo.bar.arry[n];
<printf("%d %d\n", (int) variable, (int) &foo.bar.arry[n]);
<
<...yielding two different values!?!
<
<i've noticed it twice in programs, and so far, it appears that if n=0,
<the assignment is correct, but the evaluation in printf is wrong, and
<if n=1, it's the reverse.
<
<does anyone know of cases in which lattice C screws up structure
<addresses and/or offsets?  is this why there's no option to see the 
<assembly code produced by the compiler? (1/2 :-) )

There's a known bug in 5 that causes offsets to be sign-extended.
This would cause the address to be mis-evaluated if it were more than
32K from the base of the structure.

I found this by checking the assembler ouptut via cpr (actually, it
took noticing that instructions changed between startup & execution,
and running with a watch break on them....)

<what do people recommend for a C compiler?  i need one that does a 
<fairly decent job of optimizing, but i'd also like it to be correct...

From what I've seen, Lattice seems to have fewer bugs/release than
Manx. Neither is perfect, though both do better than many people you'd
wouldn't expect it of.

I've heard rumors of a port of gcc, with unhappy results (RMS likes
using stack space).

	<mike

--
The Sword of Damocles is hanging over my head		     Mike Meyer
And I've got a feeling someone's gonna be cuttin' the thread mwm@berkeley.edu
Oh -- woe is me, My life is a misery			     ucbvax!mwm
And all I can see is I'm on the start of a pretty big downer mwm@ucbjade.BITNET

mplevine@phoenix.prineton.edu (Marshall Levine) (11/20/89)

I am in the market for a C compiler.  Is Lattice v 5.04 the latest
version?  Is it very buggy?  How much does it cost?  I heard that
Lattice gives 50% discounts to students.  Is this true?  Will 5.04
compile into USABLE assembly?  What does the 5.04 package come with?  Is
it worth even considering Manx?  Is a source-level debugger included?
How about a code profiler?  Optimization?  Does the package come with
assembly include files?  If anyone has tried the C++ compiler, is it any
good?  Will it also compile ANSI-C?  How much does it cost? Also, could
someone please send me a mailing address for Lattice (e-mail, if possible)?
Thanks in advance.



-- Marshall Levine
mplevine@phoenix.princeton.edu