Compaq C++ Question

From: Frank Wortner <frank_at_bondnet.com>
Date: Tue, 22 May 2001 14:55:53 -0400

A couple of developers walked into my office with the following program:


#include <signal.h>
#include <stdio.h>

void
main()
{
signal(SIGFPE, SIG_DFL);
printf("hello\n");
return;
}

They had named it "test.cxx" and fed it to Compaq C++ Version 6.3A.

cxx -std strict_ansi_errors test.cxx

The result they got was:

cxx: Warning: test.cxx, line 5: return type of function "main" must be "int"
main()
^
cxx: Error: test.cxx, line 7: argument of type "void (*)()" is incompatible
          with parameter of type "void (*)(int) C"
signal(SIGFPE, SIG_DFL);
---------------^
cxx: Info: 1 error detected in the compilation of "test.cxx".

The program compiles correctly without the "-std strict_ansi_errors" option,
and they want to know why. Now, I'm really old ;-), so I don't
understand a lot of C++'s ins and outs. Could anyone help me come up with a
reasonable explanation?

Thanks!

Frank
Received on Tue May 22 2001 - 18:58:03 NZST

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:42 NZDT