示例#1
0
int main(int argc, char *argv[])
{
    printf("calltest.c\n");

    printf("  Calling int    function: %d\n", int_func());
    printf("  Calling float  function: %f\n", float_func());
    printf("  Calling double function: %f\n", double_func());

    return 0;
}
示例#2
0
int main (int argc, char **argv)
{
  char char_resultval;
  short short_resultval;
  int int_resultval;
  long long_resultval;
  long long long_long_resultval;
  float float_resultval;
  double double_resultval;
  int i;

  /* A "test load" that will insure that the function really returns 
     a ${type} (as opposed to just a truncated or part of a ${type}).  */
  for (i = 0; i < sizeof (testval.ffff); i++)
    testval.ffff[i] = 0xff;

  void_func (); 				/* call to void_func */
  char_resultval      = char_func ();		/* void_checkpoint */
  short_resultval     = short_func ();		/* char_checkpoint */
  int_resultval       = int_func ();		/* short_checkpoint */
  long_resultval      = long_func ();		/* int_checkpoint */
  long_long_resultval = long_long_func ();	/* long_checkpoint */

  /* On machines using IEEE floating point, the test pattern of all
     1-bits established above turns out to be a floating-point NaN
     ("Not a Number").  According to the IEEE rules, NaN's aren't even
     equal to themselves.  This can lead to stupid conversations with
     GDB like:

       (gdb) p testval.float_testval == testval.float_testval
       $7 = 0
       (gdb)

     This is the correct answer, but it's not the sort of thing
     return2.exp wants to see.  So to make things work the way they
     ought, we'll set aside the `union' cleverness and initialize the
     test values explicitly here.  These values have interesting bits
     throughout the value, so we'll still detect truncated values.  */

  testval.float_testval = 2.7182818284590452354;/* long_long_checkpoint */
  float_resultval     = float_func ();		
  testval.double_testval = 3.14159265358979323846; /* float_checkpoint */
  double_resultval    = double_func ();		
  main_test = 1;				/* double_checkpoint */
  return 0;
}