The use of C language external variables, and the usage of extern

2010-07-21  来源:本站原创  分类:CPP  人气:167 

http://hi.baidu.com/% C3% E2% B7% D1% B4% F3% BB% B0% D0% F2% C1% D0% BA% C5/blog/item/e3b2e4cb4f2be1f453664f06.html

Description of the external variables and definition not the same thing. Description of the external variables, only stating that the variable is defined outside off in a global variable reference here ... But the definition of external variables, it is to allocate storage unit . a global variable can only be defined once, but can make multiple references.

Extern declaration with external variables, the purpose is to call in other documents. Specific use, see the following example:

file1.c file2.c

int i, j; / / define global variables extern int i, j; / / external variable declaration

char c; extern char c;

void func () void func1 ()

((

))

On external variables in file2.c i, j, c carried out instructions, you can directly call file1.c global variables defined in the

The use of static variables static

Sometimes defined in the interrupt program variables do not want to interrupt each time into the program, variables are assigned the initial value. Then we should use static variables. Static local variable at compile time, initial value, both the initial value only once. See following example:

void serial_interrupt () interrupt 4 using 3

(Static uchar i = "0";

i + +;

)

The above example, compile-time, i was assigned the initial value 0, after an interruption of each entry, i +1, and not interrupt each entry, i have been invited to zero, plus one

If the ac is necessary to call a function defined in the bc func (), need to declare the function in the ac, that the function defined in another source file. Function is called each other, so the function has external storage type of property. In principle, called a module file in the program module file other than the defined function, use the keyword extern must explain the function is called an external function. Actual use can be saved extern. The following two function declarations no significant differences:

extern int f (); and int f ();

相关文章
  • The use of C language external variables, and the usage of extern 2010-07-21

    http://hi.baidu.com/% C3% E2% B7% D1% B4% F3% BB% B0% D0% F2% C1% D0% BA% C5/blog/item/e3b2e4cb4f2be1f453664f06.html Description of the external variables and definition not the same thing. Description of the external variables, only stating that the

  • C language and the use of external variables extern usage 2010-07-21

    http://hi.baidu.com/% C3% E2% B7% D1% B4% F3% BB% B0% D0% F2% C1% D0% BA% C5/blog/item/e3b2e4cb4f2be1f453664f06.html Description of the external variables and definition not the same thing. Description of the external variables, only stating that the

  • linux shell awk access to external variables (variable-value) Introduction 2011-08-05

    Mentioned here awk, shell's friends believe that writing will come into contact. AWK is a programming language for working with text tools. AWK provides an extremely powerful: Can match the regular expression Style into Flow Control Mathematical Oper

  • Configuration database language environment variables (do not know that right) 2010-12-02

    When the date format in the case of AM or PM, and sometimes there will be ORA-01855: requirements of AM / AM or PM / PM Solution: window XP environment: Add the environment variable NLS_LANG = AMERICAN_AMERICA.UTF8 Linux follows: $ Env Add the enviro

  • C language pre-defined variables 2011-01-01

    The following parameters in the different compilers may vary, but generally are available: __LINE__ And __FILE__ variables that are dealing with the current line and current file. __DATE__ Variable represents the current date in the format month / da

  • Faramita draft language design 0.1 - truly mobile code (mobile code) 2010-04-19

    Faramita draft language design 0.1 Advertising language (not really): The real mobile code (mobile code), a real distributed computing Abbreviation explanation: RPC: Remote Procedure Call Remote Call DSL: Domain Specific Language Domain Specific Lang

  • ActionView's Magic: ERB & Binding why the page can use instance variables 2010-06-30

    Rails as a MVC framework, its core consists of three blocks: ActiveRecord, ActionController, and ActionView. Today, Bowen protagonist of this is ActionView, unlock template system magic. Typically, through scaffold has been able to create simple, con

  • C Language Learning variable memory 2010-07-21

    http://zhidao.baidu.com/question/42163882.html?fr=ala0 C language description of the variables include two aspects: the variable type and variable storage type. Variable type, such as: int (plastic), char (character) is used to describe the memory sp

  • C language variable storage types 2010-09-14

    C language variable storage types auto static extern static extern register auto local variables auto variable is a stack (stack) storage space they occupy, so that when the implementation of this section, the system will immediately allocate storage

  • Basic knowledge of C language summary of key points 2010-10-21

    Recent projects where the team is doing C development, just two days before thousands of coding to complete a 4-line program, 4 thousand lines of C program developed for people who often do C is probably nothing, but this is my development the longes

  • C language functions 2011-05-06

    Function <br /> a source file composed of one or more functions. C program execution starting from the main function, other function calls to return flow after the main function, the main function of the end of the operation of the entire program. m

  • [Written] yahoo online pen questions (c language) 2011-09-26

    Current Location: Select the type of questions>> Answer C question types: C Question | Questions: 55 questions (50 multiple choice questions, 5 Questions and Answers) Note: If you do not answer the process to submit the answer, or close your browser

  • C Programming Language Notes _1 2010-07-10

    I. INTRODUCTION tabs, length and precision formats The value and length of the EOF int and long length wihle and for statements, the first of the conditions tested, the magic number after the implementation of the loop and symbol constant function pr

  • C-global variables and local variables 2010-07-21

    http://hi.baidu.com/% C3% E2% B7% D1% B4% F3% BB% B0% D0% F2% C1% D0% BA% C5/blog/item/2d559ddc8f07e2a8cd11661d.html Variables can be three places in the program description: function within the parameters of the function or all of the functions defi

  • java based - identifiers, constants, variables, variable categories 2010-10-04

    Identifiers: 1. Java in a variety of variables, methods and class names and other elements of the sequence of characters used as identifiers Any place they can call a name identifier, are to comply with the rules of identifier 2. Java identifier nami

  • Why Lisp language was so advanced? 2010-10-20

    OF: Paul Graham Translator: Ruan Yifeng English original: Revenge of the Nerds (Excerpt from the upcoming book "Hackers and Painters" in translation) I. If we take the popular programming language to this order: Java, Perl, Python, Ruby. You wil

  • Can local variables and global variables the same name 2011-04-30

    1, the local variables and global variables can the same name? A: Yes, the local will be screened globally. Use global variables, you need to use "::" Local variables and global variables can be the same name, in reference to the variable within

  • Java Language Operators and operator precedence 2010-12-30

    Learning Tip: This section gives the Java language all operators and their usage and description, but also gives them priority for at any time. Java Language Operators and operator precedence Arithmetic operators Operator Use Description + op1 + op2

  • AS3 with javascript interaction 2009-03-25

    Also diverted to the HA, the longer the front of the shop more, hoping to calm down and put points trenches deepened. At AS2, the access to external variables passed to the flash can be accessed only through _root.value that simultaneously simply thr

  • Dynamic programming ruby 2009-09-02

    Ruby Dynamic Programming Introduced dynamic programming in ruby, first look, what is "dynamic" language: Wikipedia wrote Is a dynamic language can be changed at run time the structure of the language: for example, new functions can be introduced