Define external variable declaration, Computer Engineering

Summarize the distinction between an external variable definition and an external variable declaration.

When we have ''declared'' a variable, we have meant that we have told the compiler about the variable; i.e. its type and its name, as well as allocated a memory cell for the variable (either locally or globally). This latter action of the compiler, allocation of storage, is more properly called the definition of the variable. The stricter definition of declaration is simply to describe information ''about'' the variable.  For automatic and register variables, there is no difference between definition and declaration. The process of declaring an automatic or a register variable defines the variable name and allocates appropriate memory. However, for external variables, these two operations may occur independently. This is important because memory for a variable must be allocated only once, to ensure that access to the variable always refers to the same cell.

If an external variable is to be used in a file other than the one in which it is defined, a mechanism is needed to ''connect'' such a use with the uniquely defined external variable cell allocated for it. This process of connecting the references of the same external variable in different files, is called resolving the references.

External  variables  may  be  defined  and  declared  with  a  declaration  statement outside any function, with no storage class specifier. Such a declaration allocates memory for the variable. A declaration statement may also be used to simply declare a variable name with the extern storage class specifier at the beginning of the declaration. Such a declaration specifies that the variable is defined elsewhere, i.e. memory for this variable is allocated in another file. Thus, access to an external variable in a file other than the one in which it is defined is possible if it is declared with the keyword extern; no new memory is allocated. Such a  declaration tells  the compiler  that  the  variable  is  defined  elsewhere,  and  the code  is compiled with the external variable left unresolved. The reference to the external variable is resolved during the linking process

 

Posted Date: 6/14/2013 6:52:04 AM | Location : United States







Related Discussions:- Define external variable declaration, Assignment Help, Ask Question on Define external variable declaration, Get Answer, Expert's Help, Define external variable declaration Discussions

Write discussion on Define external variable declaration
Your posts are moderated
Related Questions
aws hosting

In a LAN network every system is identified by? In a LAN network all systems are identified through IP Address.

Hubs are present in the network To interconnect the LAN with WANs.

Pruning - Artificial intelligence Remember that pruning a search space means deciding that particular branches should not be explored. If an agent  surly  knows that exploring

the counter shown Q2Q1Q0=000 The status of Q2Q1Q0 after the pulse

Explain the Communications of Request/Response Communications requirements for message or procedural- based interaction are very similar. Application interaction (client-server

What is the difference between Leave Transaction and Call Transaction? In contrast to LEAVE TO TRANSACTION, the CALL TRANSACTION  statement causes the system to start a new SAP

A class invariant is a condition that describes all valid states for an object. It is a logical condition to make sure the correct working of a class. Class invariants must hold wh

What is a resource-allocation graph? Deadlocks can be described more precisely in terms of a directed graph known as a system resource allocation graph. This graph having of a

What are the different auto reports available in Access? The dissimilar auto reports available in Access are: Columnar AutoReport: makes a report where each row is shown ver