Keil Logo Arm Logo

Discussion Forum

How extern is used?

Next Thread | Thread List | Previous Thread Start a Thread | Settings

Details Message
Read-Only
Author
Sreenadh surendran
Posted
27-Dec-2006 06:05 GMT
Toolset
C51
New! How extern is used?

How extern can be used?

In which file the variable without extern to be declared?

Or there is no such restrictions?

Read-Only
Author
Christoph Franck
Posted
27-Dec-2006 09:33 GMT
Toolset
C51
New! RE: How extern is used?

How extern can be used?

Any C textbook should be able to explain that.

Extern is used to access global variables/functions that have been declared in another module/file.

In which file the variable without extern to be declared?

In any file. As long as there's no ambiguity.

Read-Only
Author
Andy Neil
Posted
27-Dec-2006 10:03 GMT
Toolset
None
New! RE: How extern is used?

http://c-faq.com/cpp/hfiles.html

http://c-faq.com/decl/extern.html

http://c-faq.com/decl/extarraysize.html

http://c-faq.com/aryptr/aryptr1.html

Read-Only
Author
Andy Neil
Posted
27-Dec-2006 10:08 GMT
Toolset
None
New! RE: How extern is used?

"Extern is used to access global variables/functions that have been declared in another module/file."

Actually, the global variables/functions must be defined in another module/file - extern provides just a declaration.

The definition is what actually creates the "object"; ie, allocates memory or generates code.
Every "object" must have exactly one definition.

A declaration simply provides information that an "object" is defined elsewhere.
An "object" may have many declarations.

Next Thread | Thread List | Previous Thread Start a Thread | Settings

Keil logo

Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.