Click to See Complete Forum and Search --> : atexit throwing compiler error


rawan
February 26th, 2002, 04:25 AM
I am defining a function in a C++ class which is being used in a C++ win32 console application.
I am passing that function in atexit and keep getting compiler error.
error C2664: 'atexit' : cannot convert parameter 1 from 'void (void)' to 'void (__cdecl *)(void)'
I have checked and I am including the right header files i.e stdlib.h
If anyone knows how to get this function to work would be grateful for any
suggestions.

Regards,

Riaz Awan

Alex Farber
February 26th, 2002, 06:48 AM
Try casting:


atexit( (void (__cdecl *)(void)) fn1 );




or define your exit function exactly as compiler wants:


void __cdecl fn1(void))
{
}