define

Mode: Configuration Mode

Description:

	define can be used in 2 different ways.

	1. #define

	It is being used the same way as macros in C. During
	compilation time, the define statement is being replaced
	in all the places it is called. (See Example 1.)

	The #define statement is generated in the corresponding
	package-specific header file.

	2. define

	When the define statement is used in an enumerated choice,
	it generates a #define statement for the value of the
	choice in the package-specific header file. (See Example 2.)

Example 1:

        #define MAX_NUM_IP 3
        object newbie {
                help "Newbie section";

                attribute hosts {
                    help "Newbie hosts (maximum 3)";
                    type setof ipaddr;
                    max-elements MAX_NUM_IP;
                }
            }
        }

Display 1:

        user@router# set newbie hosts ?
        Possible completions:
          <value>              Newbie hosts (maximum 3)
          [                    Open a set of values
        [edit]
        user@router# set newbie hosts [1.1.1.1 2.2.2.2 3.3.3.3] 

        [edit]
        user@router# show
        version "8.1I0 [user]";
        newbie {
            hosts [ 1.1.1.1 2.2.2.2 3.3.3.3 ];
        }

        [edit]
        user@router# commit check
        configuration check succeeds

        [edit]
        user@router# set newbie hosts 4.4.4.4 

        [edit]
        user@router# show 
        version "8.1I0 [user]";
        newbie {
            ##
            ## Warning: number of elements exceeds limit of 3
            ##
            hosts [ 1.1.1.1 2.2.2.2 3.3.3.3 4.4.4.4 ];
        }

        [edit]

Example 2:

        object newbie {
            help "Newbie section";

            attribute testing {
                type enum int {
                    choice one {
                        help "Test define";
                        value 2;
                        define MAX_TEST_NUM;
                    }
                }
            }
        }

Display 2:

        user@router# set newbie testing ?
        Possible completions:
        one      Test define

        [edit]
        user@router# set newbie testing one

        [edit]
        user@router# show newbie 
        testing one;

        [edit]

See also:
enum

Reference (to programmers guide/style guide):


© 2007-2008 Juniper Networks, Inc. All rights reserved. The information contained herein is confidential information of Juniper Networks, Inc., and may not be used, disclosed, distributed, modified, or copied without the prior written consent of Juniper Networks, Inc. in an express license. This information is subject to change by Juniper Networks, Inc. Juniper Networks, the Juniper Networks logo, and JUNOS are trademarks of Juniper Networks, Inc.
Generated on Sun May 30 20:23:12 2010 for DDL Reference Guide by doxygen 1.4.5