Define external variable declaration, Computer Engineering

Assignment Help:

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

 


Related Discussions:- Define external variable declaration

Illustrate does gas have density, Q. Illustrate does gas have density? ...

Q. Illustrate does gas have density? Answer:- Gas in addition to everything in the universe has density though some densities are not either too high or too low to be dete

Propositional inference rules, Propositional Inference Rules: Proposit...

Propositional Inference Rules: Propositional Inference Rules Equivalence rules are mostly useful because of the vice-versa aspect, that means like we can search backwards and

Human intelligence in culture - artificial intelligence, Human intelligence...

Human intelligence in culture: Understand human intelligence in culture  "AI" can be seen as just the latest tool in the philosopher's toolbox for answering questions about

Explain the role of a bus arbiter in a multiprocessor, Explain the role of ...

Explain the role of a bus arbiter in a multiprocessor configuration. Bus arbiter: Which functions to resolve priority between bus masters and allows only one device at a time t

Computer architecture, 6.How can we improve the performance of pipeline pro...

6.How can we improve the performance of pipeline processing

Describe message passing model, Q. Describe Message Passing Model? In ...

Q. Describe Message Passing Model? In message-passing model there be a set of tasks which employ their own local memories at the time of computation. Many tasks may inhabit on

Computer science, Read in integers until a zero is read in. Keep a total o...

Read in integers until a zero is read in. Keep a total of both the quantity and the sum of the negative integers and the positive integers. Once a zero is read in (signifying the

Why timing signal distributor required, Q. Why Timing Signal Distributor r...

Q. Why Timing Signal Distributor required? What do you mean by Memory Cycle? How many Memory Cycles required for following instructions: 1. ADD 2. CLEAR and ADD 3. DC

Explain working of supercomputer, Q. Explain working of Supercomputer? ...

Q. Explain working of Supercomputer? Supercomputers, capable of executing in excess of one billion floating-point operations per second (FLOPS), are very powerful, extremely hi

Explain flash devices, Explain Flash devices It is possible to read the...

Explain Flash devices It is possible to read the contents of a one cell, but it is only possible to write an whole block of cells Greater density which leads to superior cap

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd