[comp.lang.c] ANSI question

swarbric@tramp.Colorado.EDU (SWARBRICK FRANCIS JOHN) (11/23/87)

I assume that this will be the new ANSI specification.  Does MSC allow this?

void testfunc(char **str);  /* function prototype */

void testfunc(char **str)
{
  /* actual code */
}

MSC 5.0, that is.  I know Turbo C allows it.

swarbric@tramp.Boulder.EDU

atbowler@orchid.waterloo.edu (Alan T. Bowler [SDG]) (11/25/87)

In article <3086@sigi.Colorado.EDU> swarbric@tramp.Colorado.EDU (SWARBRICK FRANCIS JOHN) writes:
>I assume that this will be the new ANSI specification.  Does MSC allow this?
>
>void testfunc(char **str);  /* function prototype */
>
>void testfunc(char **str)
>{
>  /* actual code */
>}

I know the above is legal, and compilers are supposed to accept it.
I suggest that for style reasons you get into the habit of coding
the prototype as

extern void testfunc(char **str); 

The compiler may be very good at distinguishing that this is a 
proto-type and not the actual function, but humans are less
sensitive to things like semi-colon at the end of the line.
Use of "extern" says to the human reader quiet explicitly

"This is not the real definition (i.e. the one that creates it)
 That is somewhere else, but the object is used like this..."

gam3@well.UUCP (G. Allen Morris III) (11/25/87)

I would like to know what ANSI things of this code:

typedef char** GAR;

void function(GAR);

void
function(n)
char **n;
{
    ;
}

gwyn@brl-smoke.ARPA (Doug Gwyn ) (11/26/87)

In article <4531@well.UUCP> gam3@well.UUCP (G. Allen Morris III) writes:
>I would like to know what ANSI things of this code:
[example deleted]

What is your exact question?  Most of ANSI has nothing to do with C,
and the X3J11 C standards committee hasn't considered your code.  You
can probably get some feedback from X3J11 members if you ask a specific
question in this newsgroup.  Personally, I didn't think anything about
the example other than that it didn't do very much!

chip@ateng.UUCP (Chip Salzenberg) (12/02/87)

In article <11823@orchid.waterloo.edu> atbowler@orchid.waterloo.edu (Alan T. Bowler [SDG]) writes:
>
>I suggest that for style reasons you get into the habit of coding
>the prototype as
>
>extern void testfunc(char **str); 
>
>Use of "extern" says to the human reader quiet explicitly
>"This is not the real definition (i.e. the one that creates it)
> That is somewhere else, but the object is used like this..."

In fact, the construct

  extern void testfunc(char **str)
  {
	  /* Real function goes here */
  }

is legal!  Extern is the default anyway.

This kind of function declaration is generated by some C++ translators.
Microsoft C loves it, but Turbo C chokes on it. :-(

-- 
Chip Salzenberg         "chip@ateng.UUCP"  or  "{codas,uunet}!ateng!chip"
A T Engineering         My employer's opinions are not mine, but these are.
   "Gentlemen, your work today has been outstanding.  I intend to recommend
   you all for promotion -- in whatever fleet we end up serving."   - JTK