[comp.os.minix] Compiler Quirks

cgs@umd5.umd.edu (Chris G. Sylvain) (11/24/89)

Cdecl has compiled, and responds to 'declare i as int' .. after that the
interesting stuff happens...

Problem #1: The construct "FILE *yyout = stdout;" generates the error message
   "illegal initialisation".

What's the best workaround? (I've considered a few ideas, but would like to
know from the 'experts' [as they are] what is *best*)

Oh.. yes I'm using v1.3d, so this isn't a v1.2 stdio problem.
-- 
--==---==---==--
Wabe: It goes a long way before a sundial
--   ARPA: cgs@umd5.UMD.EDU     BITNET: cgs%umd5@umd2   --
--   UUCP: ..!uunet!umd5.umd.edu!cgs                    --

pcm@iwarpr4.intel.com (Phil Miller) (11/30/89)

In article <5674@umd5.umd.edu> cgs@umd5.umd.edu (Chris G. Sylvain) writes:

>Cdecl has compiled, and responds to 'declare i as int' .. after that the
>interesting stuff happens...

>Problem #1: The construct "FILE *yyout = stdout;" generates the error message
>   "illegal initialisation".

>What's the best workaround? (I've considered a few ideas, but would like to
>know from the 'experts' [as they are] what is *best*)

>Oh.. yes I'm using v1.3d, so this isn't a v1.2 stdio problem.






Try enclosing `stdio' in braces, e.g., `{stdio}'.  I have seen that work
on other compilers, though note that I haven't tried it on MINIX...




Phil Miller
pcm@iwarp.intel.com

ghelmer@DSUVAX.uucp (Guy Helmer) (12/01/89)

In article <5296@omepd.UUCP>, pcm@iwarpr4.intel.com (Phil Miller) writes:
> In article <5674@umd5.umd.edu> cgs@umd5.umd.edu (Chris G. Sylvain) writes:
> 
> >Cdecl has compiled, and responds to 'declare i as int' .. after that the
> >interesting stuff happens...
> >Problem #1: The construct "FILE *yyout = stdout;" generates the error message

Is this a compiler error message, or Cdecl message?

> 
> Try enclosing `stdio' in braces, e.g., `{stdio}'.  I have seen that work
> on other compilers, though note that I haven't tried it on MINIX...

Assuming that this is a compiler error message, 
why would this work at all?  stdin, stdout, and stderr are defined as
#define stdin	(_io_table[0])
#define stdout	(_io_table[1])
#define stderr	(_io_table[2]) in stdio.h (protected mode 1.4 version)
and the array of file pointers, _io_table, isn't filled with real
pointers until run time under Minix.  Is yyout auto or static?
If yyout is auto, this should work if the compiler would accept it, but
I'm assuming that this is a 
static declaration that the compiler wants to initialize at compile
time.  More input, please?
 
> Phil Miller
> pcm@iwarp.intel.com


-- 

 Guy Helmer                                           ghelmer@dsuvax.uucp
 Dakota State University Computing Services           helmer@sdnet.bitnet

cgs@umd5.umd.edu (Chris G. Sylvain) (12/03/89)

-- In our last episode ;-)  ---

> Problem #1: The construct "FILE *yyout = stdout;" generates the error
>   message "illegal initialisation".
>
> What's the best workaround?

I threw a "yyout = stdout;" in main() before I posted, but I wasn't convinced
that was "best". It was the consensus of the helpful replies that that was
exactly the workaround to use. Thanks to those who kindly responded!

-- Today's "episode":

Please note the "illegal initialisation" message was generated only for the
SECOND construct in the code. It had taken "FILE *yyin = stdin;" on the
previous line without complaining. In any case, yyin and yyout are now set
separately from their declarations.

Problem #2: /usr/lib/opt dies with the error message "assertion failed file
  peephole.c, line 172". Is there a way around opt? I've turned on as much
  cdecl debugging code as I can (opt runs out of memory!). I've chmem'ed opt
  as far as it'll go already (and back a bit again for safety).
     With the debugging strings in the code, it's now about 12k text, 17k data.

Problem #3: The substitute code for NOVARARGS apparently doesn't pick things
  off the stack properly. Could a ACK guru (or anyone familiar with the ACK
  stack layout) see what's wrong with these few lines ?

   /*
    *	it is assumed here that machines which don't have either
    *	<varargs.h> or <stdarg.h> will put its arguments on
    *	the stack in the "usual" way and consequently can grab
    *	the arguments using the "take the address of the first
    *	parameter and increment by sizeof" trick.
    */
# define VA_DCL(type,var)		(var) type var;
# define VA_START(list,var,type)	(list = (va_list)&(var) , (var))
# define va_arg(list,type)		((type *)(list += sizeof(type)))[-1]
# define va_end(p)			/* nothing */
typedef char *va_list;

..and I thought this'd be a piece of cake! Silly me!!-)
-- 
--==---==---==--
Rath: A sort of green pig
--   ARPA: cgs@umd5.UMD.EDU     BITNET: cgs%umd5@umd2   --
--   UUCP: ..!uunet!umd5.umd.edu!cgs                    --