Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C - <b>auto automatic data storage class</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
auto                     Automatic Data Storage Class

    The automatic class specifies that an object is to be created
    dynamically.  The auto keyword may only be used internal to a
    function. An auto variable  is created on the run-time stack when its
    parent function is invoked, and it is destroyed when that function
    exits. An auto object has temporary life, and its scope is limited to
    the block in which it is declared, and all subordinate blocks (if
    any).

     [auto] [type] identifier [[= initializer], ... ] ;

      Notes:    The initial value of an auto variable is undefined if it
                is not explicitly initialized, either in the initializer
                list or via assignment.  The initializer expression can
                be any valid run-time expression, including function
                calls.  Note that auto arrays, structures and unions may
                not have initializer lists.

                Since C permits declarations to occur at the beginning of
                any block (or compound statement), it is possible to use
                the same identifier for two different variables at
                different block levels. This is generally construed as a
                bad programming practice.  While execution proceeds in
                the inner block, the identifier of the same name in the
                outer block is hidden.

                Since the auto class is the default class for all
                internal variable declarations, the keyword auto is very
                rarely specified. If the type is omitted and auto is
                specified, type int is assumed.

                Formal arguments in a function definition that have no
                class keyword are treated like automatic variables.

                Excess register variables are treated as if they had
                class auto.

                Since the execution path of a program may vary from run
                to run, the amount of stack space needed for auto
                variables will vary accordingly.

                You only have a finite stack size, so the default
                behavior is to check for potential stack overflow each
                time a function is called. (This checking can be over-
                ridden using the compile-time switch /Gs and the
                preprocessor #pragma check_stack directive.)  A default
                stack size of 2K bytes is provided.

                If you use a large amount of auto data or have heavily
                recursive algorithms, you may get a "stack overflow"
                message.  You can increase or decrease your stack size
                using the MS-LINK switch /STACK. The size can also be
                changed without relinking, using the EXEMOD utility.

                There is no easy way to know exactly what your stack
                requirements are, since not only is stack space used for
                auto (and unused register) variables, it is also used for
                function call argument lists and temporary variables
                generated by the compiler and the run-time library.

  -------------------------------- Example ---------------------------------

           auto int max = 1234;
           auto struct date today;
           double average;                   /* defaults to auto */
           auto int i = f(1234) + 10;



See Also: Classes register Switches #pragma

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson