Constants allow you to calculate the value of an expression and store it. Compare constants with preprocessor constants. Preprocessor is run before compilation of source file occurs and therefore has limited expression evaluation capabilities.

Syntax:

const name-id = value-expr;
      

Constants are allowed in any scope. If a constant is used in global scope, a value-expr must be constant. If a constant is used in the scope of user-defined type, a value-expr may not be a constant expression:

const MyConstant = 5;  // valid, constant expression

struct A
{
    int a;
    const double_a = a * 2;    // valid, non-const expression are allowed in non-global scope
};
      

Optimizations

Hex Editor Neo performs an optimization when it compiles constant definitions. All constant expressions are evaluated to their numeric equivalents. Hex Editor Neo does not optimize a constant part of a non-constant expression.

const MyConstant = 60 * 60;    // will be optimized directly to 3600
const PI = 3.1415926;
const _2PI = 2 * PI;        // will be optimized directly to 6.2831852
        

Constant Arrays

You can use the following syntax to declare an array:

const name-id [ ] = { initializer-list };
        

Where name-id is a name of array and initialize-list is a comma-separated list of expressions that initialize array elements.

See Also