Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


what is difference b/w extern & volatile variable??

Answers were Sorted based on User's Feedback



what is difference b/w extern & volatile variable??..

Answer / antonio leite

extern states that a variable is referenced in a module but
is declared in another module. This makes the linker not
generate an error/warning when the extern variable is
referenced but wait till the declaration is stated in a
module.
volatile states that the value of a variable can be changed
anywhere in the code. This is used by the optimizer to know
that a piece of code must not be optimized when a volatile
variable is found. For example, when a variable is changed
by a interrupt timer it must be declared volatile. The code
seems to be always true because Timer_xpto seems to be
always > 0. If the code is optimized, the if would simply
disapper from the code, but this is not what the programmer
wants, so declare
extern volatile unsigned long Timer_xpto;
so that the compiler will never optimize the code below.

Timer_xpto = 100;
do something
if (Timer_xpto > 0 )
{
do any other thing
}

Here extern is stating that the variable is declared in
other module and volatile that the code where the
Timer_xpto appears must not be optimized.
See http://www.eetimes.com/discussion/programming-
pointers/4025609/Place-volatile-accurately

Is This Answer Correct ?    13 Yes 0 No

what is difference b/w extern & volatile variable??..

Answer / sathya

extern keyword is used to strike the global declaration.
but volatile its indirectly change the values in externally

Is This Answer Correct ?    5 Yes 1 No

what is difference b/w extern & volatile variable??..

Answer / mchilakala

Extern keyword specifies that the variable had been
declared globally where as volatile keyword specifies that
there is a chance of changing it's value by external
conditions.
Ex:
if we declare a variable as

"Volatile date=03/08/2011"
then output is 03/08/2011
then after one day the output will change to 04/08/2011.

Is This Answer Correct ?    3 Yes 0 No

what is difference b/w extern & volatile variable??..

Answer / anonimos

volatile variables are used on RT Embedded systems to
interface a physical memory mapped/IO mapped cell on the
computer board (volatile pointer).

Example define IO port:
#define PortA (*(volatile unsigned char *)0x3b)
unsigned char inputValue=PortA;

optimization may attempt to perform paging to hard drive of
to cache or even CPU registers so when reading from the
physical location in Mem/IO space the program will actually
read old value that was paged/cached by optimization
algorithm of the computer/board, even after the Input
changed on this Memory/IO cell.

volatile instruct the compiler to prevent optimization by
caching to registers/cache.

Is This Answer Correct ?    1 Yes 0 No

what is difference b/w extern & volatile variable??..

Answer / mani

extern variables are stored in CPU ,volatile variables are
temporary.

Is This Answer Correct ?    4 Yes 10 No

what is difference b/w extern & volatile variable??..

Answer / deepa

extern is a keyword used to declare variables as global
varible.volatile variables are temporary variable

Is This Answer Correct ?    1 Yes 7 No

Post New Answer

More C Interview Questions

Explain zero based addressing.

0 Answers  


Why is c faster?

0 Answers  


Write a program to generate the first n terms in the series --- 9,11,20,31,...,82

1 Answers   Cognizant,


Write a program to write a given string in maximum possibilities? i.e str[5]="reddy"; i.e we can write this string in 120 ways for that write a program

3 Answers   Subex,


Write a C++ program to generate 10 integer numbers between - 1000 and 1000, then store the summation of the odd positive numbers in variable call it sum_pos, then find the maximum digit in this variable regardless of its digits length.

0 Answers  


Where are c variables stored in memory?

0 Answers  


Write a C program to check a number even or odd, without using any relational, arithmetic operator and any loops.

1 Answers  


Can we compile a program without main() function?

0 Answers  


Is c is a low level language?

0 Answers  


Explain how does free() know explain how much memory to release?

0 Answers  


Explain what is the benefit of using #define to declare a constant?

0 Answers  


What is gets() function?

0 Answers  


Categories