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??

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the similarities between c and c++?

1002


Explain about C function prototype?

1026


What is multidimensional arrays

1064


Is there any demerits of using pointer?

1015


How can I call system when parameters (filenames, etc.) Of the executed command arent known until run time?

1031


main() { int i = 10; printf(" %d %d %d ", ++i, i++, ++i); }

1090


can any one please explain, how can i access hard disk(physical address)? it is possible by the use of far,near or huge pointer? if yes then please explain......

1809


When we use void main and int main?

1018


Why is c called c not d or e?

1048


Do character constants represent numerical values?

1286


What are the Advantages of using macro

1115


How do we print only part of a string in c?

974


List a few unconditional control statement in c.

929


What happens if a header file is included twice?

985


What are the types of assignment statements?

1006