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.)
#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; } } }
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]
object newbie { help "Newbie section"; attribute testing { type enum int { choice one { help "Test define"; value 2; define MAX_TEST_NUM; } } } }
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]