Use of 'static' keyword

This is a discussion on Use of 'static' keyword within the C Programming forums, part of the General Programming Boards category; In the following code, would static be used just to keep the function sig_usr() file scoped? Or this there more ...

  1. #1
    Registered User
    Join Date
    Jan 2006
    Location
    Berkeley, Ca
    Posts
    195

    Use of 'static' keyword

    In the following code, would static be used just to keep the function sig_usr() file scoped? Or this there more to using static in this example.

    Code:
    #include <signal.h>
    #include <stdio.h>
    #include <unistd.h>
    
    static void sig_usr(int signo) {
        if(signo == SIGUSR1)
            printf("received SIGUSR1\n");
    
    }
    
    int main(void) {
        if (signal(SIGUSR1,sig_usr) == SIG_ERR)
            fprintf(stderr,"can't catch signal");
        for(;;)
            pause();
    }

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,434
    That's all there is to it.

  3. #3
    Registered User
    Join Date
    Jan 2006
    Location
    Berkeley, Ca
    Posts
    195
    Okay. Thanks.

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. seg fault at vectornew
    By tytelizgal in forum C Programming
    Replies: 2
    Last Post: 10-25-2008, 01:22 PM
  3. uploading file to http server via multipart form data
    By Dynamo in forum C++ Programming
    Replies: 1
    Last Post: 09-03-2008, 04:36 AM
  4. LNK2001 ERROR!!! need help
    By lifeafterdeath in forum C++ Programming
    Replies: 7
    Last Post: 05-27-2008, 05:05 PM
  5. get keyboard and mouse events
    By ratte in forum Linux Programming
    Replies: 10
    Last Post: 11-17-2007, 04:42 PM

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