Function pointer Q

This is a discussion on Function pointer Q within the C Programming forums, part of the General Programming Boards category; I'm trying to catch a signal interrupt. The docs on signal() say if the func pointer is equal SIG_DFL then ...

  1. #1
    Registered User
    Join Date
    Nov 2008
    Posts
    119

    Function pointer Q

    I'm trying to catch a signal interrupt. The docs on signal() say if the func pointer is equal SIG_DFL then the default action is taken. SIG_DFL looks like (void (*)(int))0. Why is there a number at the end of the function pointer? How do I declare a function that looks like that?

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    That is the number zero, cast to a function pointer, and therefore represents Not An Actual Function (much like NULL represents Not An Actual Memory Address).

  3. #3
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,832
    Your own interrupt function would be
    Code:
    void abc(int x) {
    /* do stuff with parameter x */
    }
    Then you'd tell the system that's your function: signal( number, abc)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. passing method pointer as a function pointer
    By sevcsik in forum C++ Programming
    Replies: 5
    Last Post: 12-30-2007, 05:19 AM
  2. Replies: 7
    Last Post: 07-04-2007, 12:46 PM
  3. Replies: 9
    Last Post: 01-02-2007, 03:22 PM
  4. Replies: 4
    Last Post: 11-05-2006, 01:57 PM
  5. Replies: 6
    Last Post: 11-29-2004, 07:50 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21