Thread: atexit function

  1. #1
    Registered User
    Join Date
    Nov 2006

    atexit function

    I am using the atexit function for one of my c codes and everything works fine except I get an error message from the compiler which reads:

    warning C4113: 'void (__cdecl *)()' differs in parameter lists from 'void (__cdecl *)(void)'

    What does this mean? It refers to this line of code:
    I have tried to prototype this but it brings more warnings. Maybe I am doing this wrong. What would be your coding to prototype this function?



  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Are you compiling your C code with a C++ compiler?
    The function passed to atexit needs to be a C function, not something name mangled by a C++ compiler.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Did you prototype your function like this
    void thank_you();
    rather than like this?
    void thank_you(void);
    There's a difference. void inside the parameter list means, to C and C++ compilers, that the function takes no parameters. Nothing inside the parameters list means (to a C compiler) that no information about the parameters is available -- the function could take no arguments or twenty. (To a C++ compiler, nothing inside the argument list is the same as void.)

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell

    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ:

    My website:
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  2. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  3. In over my head
    By Shelnutt2 in forum C Programming
    Replies: 1
    Last Post: 07-08-2008, 06:54 PM
  4. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  5. const at the end of a sub routine?
    By Kleid-0 in forum C++ Programming
    Replies: 14
    Last Post: 10-23-2005, 06:44 PM