www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/04/24/09:49:12

Date: Thu, 24 Apr 1997 15:35:03 +0200 (MET DST)
From: Miguel Murillo <mmurillo AT ideafix DOT cps DOT unizar DOT es>
To: Ian Mausolus <mausolus AT ican DOT net>
cc: djgpp AT delorie DOT com
Subject: Re: C & static
In-Reply-To: <01bc5055$7a3d2100$08b0f8ce@didi>
Message-ID: <Pine.LNX.3.95.970424150643.25520D-100000@ideafix.cps.unizar.es>
MIME-Version: 1.0


On 24 Apr 1997, Ian Mausolus wrote:

> 
> What is the significance of the word "static" in front of a function name
> in C?
> 
> for example:
> 
> static void foo(int i)
> {
>   ....
> }
> 
> thanx,
> 
> I. Mausolus
> 

Static : function local in current file  

   file1                          file2 
   ------                         ------- 
|   static void foo()        static int foo()   |
|   {  /*...*/}              {   /*...*/  }     |
|   void F(){ foo();}	     int G(){ foo();}	|	
 -----------------------------------------------
	file1.o		H       file2.o
			H
		link	H
			V
OK!		       EXE	

   file1                          file2
   ------                         -------
|     void foo()                    int foo()   |
|   {  /*...*/}              {   /*...*/  }     |
|   void F(){ foo();}        int G(){ foo();}   |
 -----------------------------------------------
        file1.o         H       file2.o
                        H
                link    H   Linking Error! 
                        V
                       EXE

BAD...!!!

Good luck!!

Miguel

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019