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

Why gateways are used during mail transfer, Why Gateways are used during ma...

Why Gateways are used during mail transfer? Email using SMTP effort best while both the sender and the receiver are on the internet and can hold TCP connections in between send

What is access latency and rotation speed, Q. What is Access latency and Ro...

Q. What is Access latency and Rotation Speed? Access latency: A disk access basically moves the arm to selected cylinder and waits for rotational latency that may take less t

Show the features of a typical floating-point representation, Q. Show the F...

Q. Show the Features of a typical floating-point representation? The features of a typical floating-point representation of 32 bits in above figure are: Left-most bit is

Generic techniques developed - artificial intelligence, Generic Techniques ...

Generic Techniques Developed: In the pursuit of solutions to various problems in the above categories, various individual fundamental techniques have sprung up which have been

Real-time systems, This document is intended to help students get started w...

This document is intended to help students get started with the real-time systems (RTS) assignment. We will start on the assignment together in the laboratory. Students will then c

Show the liability of cpu in interrupt cycle, Q. Show the liability of CPU ...

Q. Show the liability of CPU in interrupt cycle? In the interrupt cycle the liability of CPU/Processor is to ensure whether any interrupts have happened checking presence of in

Write a program to find the area and perimeter of a circle, Write a program...

Write a program to find the area and perimeter of a circle of given radius # include void main() { float radius, area, perimeter, pi=3.14; printf("\nEnter the rad

An example of two stages network have switching elements, For two stages ne...

For two stages network the switching elements for M inlets with r blocks and N outlets with s blocks is given by (A) Ms + Nr                                (B)  Mr + Ns (

Convert, haw to convert context free grammar to regular grammar

haw to convert context free grammar to regular grammar

What is deadlock in operating system, Explain Deadlock in operating system ...

Explain Deadlock in operating system ? Deadlock: all process in a set of processes is waiting for an event which only a process in the set can cause.

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