Function declarations (was: MSC v5.1 Bug???)

Larry Jones scjones at sdrc.UUCP
Tue Aug 23 07:02:05 AEST 1988


In article <5680 at rpp386.UUCP>, jfh at rpp386.UUCP (The Beach Bum) writes:
> In article <11879 at iuvax.cs.indiana.edu> bobmon at iuvax.UUCP (RAMontante) writes:
> >Craig Dawson asks about a program in which two routines try to call a
> >third, somewhat as follows:
> >
> >x() { static z(); z(); }
> >y() { static z(); z(); }
> >
> >static z() { ; }
> >
> >(MSC apparently chokes; BTW, TurboC accepts it.) 
> 
> the msc compiler is broken.  the code should compile without error
> as written (more or less ...)

NO!!!  Amazingly enough, MSC got this right - the code is wrong.  Think about
this similar code:
  x() { static z[]; z[0] = 3; }
  y() { static z[]; z[0] = 5; }

  static z[10];
You wouldn't expect that to work, would you?  If something is declared within
a block, it must be defined within the same block unless it is declared extern.
Since you can't define functions within a block, you can't declare a static
function within a block.  Sorry.

----
Larry Jones                         UUCP: uunet!sdrc!scjones
SDRC                                      scjones at sdrc
2000 Eastman Dr.                    BIX:  ltl
Milford, OH  45150                  AT&T: (513) 576-2070
Nancy Reagan on superconductivity: "Just say mho."



More information about the Comp.lang.c mailing list