[comp.sys.next] short int in GNU cc

jefft@chirality.rsa.com (Jeff Thompson) (03/12/91)

Hi there,

I want to use prototyping in my NeXT GNU C program for a function which 
takes a short int as an argument, such as:

int MyFunc (short int);

int MyFunc (x)
short int x;
{
}

I get the error: 
  argument `x' doesn't match function prototype
  a formal parameter type that promotes to `int' can match only `int' in
    the prototype.

How can I keep using prototypes without having to change all my functions to
pass `int' instead of `short int' ?

Thanks in advance,
Jeff Thompson

melling@cs.psu.edu (Michael D Mellinger) (03/13/91)

In article <JEFFT.91Mar11163703@chirality.rsa.com> jefft@chirality.rsa.com (Jeff Thompson) writes:

   Hi there,

   I want to use prototyping in my NeXT GNU C program for a function which 
   takes a short int as an argument, such as:

   int MyFunc (short int);

   int MyFunc (x)
   short int x;
   {
   }

   I get the error: 
     argument `x' doesn't match function prototype
     a formal parameter type that promotes to `int' can match only `int' in
       the prototype.

   How can I keep using prototypes without having to change all my functions to
   pass `int' instead of `short int' ?

Declare your functions like this:

   int MyFunc (short int);

   int MyFunc (short int x)
   {
   }

You were mixing the old style C declarations with the new style.

-Mike


BTW: Old style obsolete, don't use.