ILE C/C++ Programmer's Guide

Example of Function Prototype Mismatch

Figure 230. Example of Type Mismatch


#include <signal.h>
void (*sig_handler)(int);(1)
typedef void (*SIG_T)();      // function pointer typedef of type void (*) ()(2)
 
extern "C" void (*signal (int, void(*) (int))) (int); // function pointer prototype 
                                                      // with return type void(*) (int)(1)
SIG_T oldsig = signal (SIGALL, sig_handler);     // function pointer definition of type SIG_T
 

Notes:

  1. Because of the type mismatch between the type defined in function pointer prototype ("void(*) ()") and the type definition in the function prototype (void (*) (int)), the example generates the following error:
    CZP0257(30) An object or reference of type "void (*)()" cannot be
      initialized with an expression of type "extern "C" void (*)(int)"
    

  2. The int parameter does not exist in the type definition SIG_T.


[ Top of Page | Previous Page | Next Page | Table of Contents ]