Re: Why some code for certain events declared to be static???



    Chris> GTK+ Tutorial has scribble.c code that has many subroutines that
    Chris> are tied to events.

    Chris> Many of these are static.  Please explain what static gives you
    Chris> in C.

In a small standalone application like scribble it doesn't really buy you
much, but if you are writing a more significant application, using static to
restrict the visibility of functions only used local to the file they are
declared in reduces global namespace pollution and thus the chance for
conflicts at compile or link time.  Just to provide a dumb example, suppose
you named an event handler "connect".  If it's not declared static it will
conflict with the standard library function of the same name.

-- 
Skip Montanaro (skip pobox com - http://www.mojam.com/)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]