Thread: warning: implicit declaration of function `sigset', `sighold' & `sigrelse'

  1. #1
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545

    warning: implicit declaration of function `sigset', `sighold' & `sigrelse'

    OK, I almost have this thing building cleanly, but I'm seeing these warnings:
    Code:
    warning: implicit declaration of function `sigset'
    warning: implicit declaration of function `sighold'
    warning: implicit declaration of function `sigrelse'
    Even though that .c file includes <signal.h>
    Am I missing something, or does RedHat Enterprise 3.0 not support those functions?

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129

  3. #3
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by robwhit View Post
    So I need to add this before including <signal.h>?
    Code:
    #define _XOPEN_SOURCE 500

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    presumably.

  5. #5
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    OK this is weird.
    I added the #define _XOPEN_SOURCE 500 right before including <signal.h>, but it's still giving me those warnings.
    What the hell???

  6. #6
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Does it link correctly, if you ignore the warnings - not saying ignoring them is a good thing - but if you also get an error at the link phase with problems with the same symbold, I'd recommend that you replace the sigset, et.al. with the signal() et.al equivalents.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  7. #7
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Hmm... After I moved the #include <signal.h> before any other #include, it worked.

    Now I'm getting:
    Code:
    warning: passing arg 2 of `sigset' from incompatible pointer type
    for the following 2 calls to sigset:
    Code:
    oldchld = (void(*)()) sigset(SIGCHLD, _sci_reaper_);
    if (oldchld == SIG_ERR) {
    	sprintf(prtbuf, "sigset call failed with errno %d", errno);
    	sci_prt( prtbuf);
    	oldchld = SIG_DFL;
    }
    oldterm = (void(*)()) sigset(SIGTERM, _sci_terminate_);
    if (oldterm == SIG_ERR) {
    	sprintf(prtbuf, "sigset call failed with errno %d", errno);
    	sci_prt( prtbuf);
    	oldterm = SIG_DFL;
    _sci_reaper_ is defined as:
    Code:
    static void _sci_reaper_();
    But sigset() is defined as:
    Code:
    typedef void (*sighandler_t)(int);
    sighandler_t sigset(int sig, sighandler_t disp);
    <sigh>
    Should I add the int parameter to the _sci_reaper_ functions and just ignore it? What is the int used for?

  8. #8
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by cpjust View Post
    What is the int used for?
    It holds the number of the signal which caused the handler to be invoked. It sounds useless until you realize that you can handle many different signals all with the same handler function.

  9. #9
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    OK, I'm totally buffudled, so I'm just gonna add the int parameter and ignore it.
    I think this code it only used for the test harness anyways.

  10. #10
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by cpjust View Post
    OK, I'm totally buffudled, so I'm just gonna add the int parameter and ignore it.
    I think this code it only used for the test harness anyways.
    Don't be befuddled :-)

    Imagine that you're handling the SIGINT signal and the SIGUSR1 signal both with the same handler function. How does this function know which signal it received? The signal number is in that integer.

  11. #11
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by brewbuck View Post
    Imagine that you're handling the SIGINT signal and the SIGUSR1 signal both with the same handler function. How does this function know which signal it received? The signal number is in that integer.
    Yeah, I understand that part (sort of). But since the old code never did anything with that int, I'm guessing I don't need to worry about it either?
    All those handler functions do is:
    Code:
    static void
    _sci_reaper_()
    {
    	signalled++;
            while ( _sci_dowait_(0) )       /* non-blocking wait */
                    ;
    }
    
    static void
    _sci_terminate_()
    {
    	signalled++;
    	if ( mypid == (PID_TYPE) 0 ) {
    		shut_down = 2;
    	}
    }

  12. #12
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    The code as it stands should be OK, but if you ever run this on a system where the callee cleans the stack, then you'd have stack corruption because the function is called with a parameter but the function itself is not aware of this parameter. [This is a rather unlikely scenario as long as we are discussing normal Linux/Windows calls.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  13. #13
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    To get rid of the warning, I just added ( int i ) parameters to the functions and then didn't do anything else with them.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Errors including <windows.h>
    By jw232 in forum Windows Programming
    Replies: 4
    Last Post: 07-29-2008, 01:29 PM
  3. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  4. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  5. <regex.h> help needed! C slower than Java
    By bobk544 in forum C Programming
    Replies: 9
    Last Post: 02-06-2005, 06:03 AM