Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Use of static ?

Reply
Thread Tools

Use of static ?

 
 
Barry Schwarz
Guest
Posts: n/a
 
      10-16-2005
On Sun, 16 Oct 2005 12:01:05 -0400, Joe Wright <(E-Mail Removed)>
wrote:

>Simon Biber wrote:
>> Joe Wright wrote:
>> [...]
>>
>>> Because objects at file scope have static storage class by default,
>>> the static keyword can take on another meaning. Also by default,
>>> objects and functions defined at file scope enjoy external linkage,
>>> meaning they can be 'seen' by the linker and therefore used by other
>>> modules in the program. Now here at file scope, we can qualify an
>>> object as 'static' and block its otherwise external linkage. The
>>> object or function is no longer visible to the linker and therefore
>>> cannot be used by other modules.

>>
>>
>> The object or function cannot be *directly* used by other modules.
>> However, it is still accessible in memory, and can be used by other
>> modules if a pointer to it is passed between modules.
>>

>
>You misunderstand. The modules are compiled separately and then linked
>together into an executable. There is no passing of pointers among
>modules. Once linked, it's all one program. There are no modules anymore.


If the modules are linked together, it is more than likely that
functions are being called from one module to another. It is also
likely that these function calls involve arguments and return values.
We will have to take your word for it that none of these arguments or
return values are of type pointer to something but that is not very
likely.


<<Remove the del for email>>
 
Reply With Quote
 
 
 
 
Joe Wright
Guest
Posts: n/a
 
      10-16-2005
Barry Schwarz wrote:
> On Sun, 16 Oct 2005 12:01:05 -0400, Joe Wright <(E-Mail Removed)>
> wrote:
>
>
>>Simon Biber wrote:
>>
>>>Joe Wright wrote:
>>>[...]
>>>
>>>
>>>>Because objects at file scope have static storage class by default,
>>>>the static keyword can take on another meaning. Also by default,
>>>>objects and functions defined at file scope enjoy external linkage,
>>>>meaning they can be 'seen' by the linker and therefore used by other
>>>>modules in the program. Now here at file scope, we can qualify an
>>>>object as 'static' and block its otherwise external linkage. The
>>>>object or function is no longer visible to the linker and therefore
>>>>cannot be used by other modules.
>>>
>>>
>>>The object or function cannot be *directly* used by other modules.
>>>However, it is still accessible in memory, and can be used by other
>>>modules if a pointer to it is passed between modules.
>>>

>>
>>You misunderstand. The modules are compiled separately and then linked
>>together into an executable. There is no passing of pointers among
>>modules. Once linked, it's all one program. There are no modules anymore.

>
>
> If the modules are linked together, it is more than likely that
> functions are being called from one module to another. It is also
> likely that these function calls involve arguments and return values.
> We will have to take your word for it that none of these arguments or
> return values are of type pointer to something but that is not very
> likely.


No. Once linked into an executable there are no modules. It is one
program and a function can call another directly without any regard for
which source or object module it was in originally. The functions may
indeed involve pointers and return values but they have nothing to do
with which module the were in or which module they were called from.
Once linked, there are no modules.

--
Joe Wright
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
 
Reply With Quote
 
 
 
 
Michael Wojcik
Guest
Posts: n/a
 
      10-17-2005

In article <(E-Mail Removed)>, Joe Wright <(E-Mail Removed)> writes:
>
> You misunderstand. The modules are compiled separately and then linked
> together into an executable. There is no passing of pointers among
> modules. Once linked, it's all one program. There are no modules anymore.


This is true of some implementations, but not all. In EPM C on the
AS/400, for example, each translation unit becomes a separate "*PGM
object", which exists as the equivalent of a separate file in the
filesystem; and at runtime, when one *PGM object refers to a symbol
with external linkage in another *PGM object, that object is loaded
and dynamically bound to the running job (if it hasn't already been).
There's a link step, but it only serves to associate *PGM object
names with the external-linakge symbols they define.

In short, in this implementation, there are modules after program
creation. C does not require that a linker create a single "program"
entity which removes module boundaries.

--
Michael Wojcik http://www.velocityreviews.com/forums/(E-Mail Removed)

Art is our chief means of breaking bread with the dead ... but the social
and political history of Europe would be exactly the same if Dante and
Shakespeare and Mozart had never lived. -- W. H. Auden
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PIX public/24 ip static mapping means 256 times interfaces static maps? Nieuws Xs4all Cisco 2 05-26-2005 06:25 PM
PIX public/24 ip static mapping means 256 times interfaces static maps? Nieuws Xs4all Cisco 0 05-26-2005 11:07 AM
Static is REALLY Static! Paul W ASP .Net 2 05-03-2005 10:12 AM
Static classes with static members Ben ASP .Net 3 06-01-2004 07:43 PM
Static vs. non-static connection Natan ASP .Net 8 05-26-2004 08:21 AM



Advertisments