Structure Viewer supports advanced structure definition syntax. It is based on the Standard C type definition syntax and extends it in a number of ways.

While Standard C only allows defining static types, that is, data structures which size and memory allocation is strictly defined at compile time, Hex Editor Neo extends the syntax to allow definition of dynamic types.

The following code illustrates this:

struct StaticType
{
    int Array[128];
};

struct DynamicType
{
    int ArraySize;
    int Array[ArraySize/sizeof(int)]; // invalid in Standard C (non const expression), valid in Hex Editor Neo
};
      

The DynamicType structure definition is valid in Hex Editor Neo. The size of the structure is determined at the time it is bound to the data and the number of elements in Array array varies.

Workflow

When you add a source file to the Structure Library the following steps are performed:

  1. A preprocessor is run on the source file. Preprocessor is responsible for the following tasks:
    • Elimination of all comments from the source file.
    • Macro evaluation.
    • Processing of conditional compilation blocks.
    • Processing of all #include directives and building the dependency graph.
  2. Hex Editor Neo searches for a precompiled file for a given source file. If it is found (and is up to date), processing continues on step 5.
  3. A source file is compiled and optimized. Optimization includes, for example, simplifying all constant expressions.
  4. Precompiled file is created (it is saved into the %TEMP% folder).
  5. Precompiled file is loaded. All user-defined types in a structure are ready to be used.

When you instruct the Hex Editor Neo to bind one of the defined structures, it uses the information from the precompiled file to quickly bind the structure definition to real document data. Time-cost preprocessing and compilation is not required in this case.

Tokenization

Source files are tokenized according to standard C language rules: there must be one or more space characters between tokens if they cannot be distinguished without spaces and there may optionally be one or more spaces between tokens if they are distinguishable without spaces.

Space is a space character (' '), tabulation ('\t'), newline ('\n') or comment.

int a;              // valid, space is used to separate tokens "int" and "a"
int/* comment */a;  // valid, comment  is used to separate tokens "int" and "a"
inta;               // invalid, compiler cannot distinguish between "int" and "a" and parses it as "inta"
int                 // continued on the next line…
     a              // still continued…
          ;         // valid, newline is valid space character
    
a & b               // valid, space is used to separate "a" and "&" and "&" and "b"
a&b                 // still valid, space is not required - compiler is able to 
                    // distinguish between "a" (identifier) and "&" (operator)
        

Space must not be used inside a keyword, such as built-in type "int" or operator "&&":

in t a;       // invalid, "int" must not contain space
a & & b       // valid, but will be parsed as a & (&b)
a | | b       // invalid, space inside keyword (operator "||")
        

See Also