CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2002
    Posts
    2

    atexit throwing compiler error

    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


  2. #2
    Join Date
    Dec 2001
    Posts
    381

    Re: atexit throwing compiler error

    Try casting:


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




    or define your exit function exactly as compiler wants:


    void __cdecl fn1(void))
    {
    }






Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured