Overview

Structure Definitions support various #pragma directives to control the properties of structure definitions.  Like C/C++ pragma usage, the directives can be placed in different locations to control properties of elements defined after it.  

Structure Setting #pragma directives must be defined within a structure definition.

With Structure #pragma directives, users can control:

#pragma ptrsize(<n>)

The structure viewer treats pointers to structures or data types as an absolute location to that data.  For example, adding "UWord* myValue" to a structure definition is interpreted as "the next data (value) within the document represents an absolute value to a UWord".

By default, pointers are assumed to be 32bit.  The ptrsize pragma directive can be used to change the default pointer size to 8 bit, 16bit, 32 bit, or 64 bit.

#pragma ptrsize(1) // Set pointer size to 8 bit

#pragma ptrsize(2) // Set pointer size to 16 bit

#pragma ptrsize(4) // Set pointer size to 32 bit

#pragma ptrsize(8) // Set pointer size to 64 bit

 

NOTE: #pragma ptrsize is allow outside structure definitions.  See Library Settings for other definitions allowed outside a structure definition.

 

#pragma lockAt(n)
#pragma floatAt(n)

The lockAt and floatAt pragma commands are used to suggest an initial locked or floating offset.  If specified, the add structure dialog will pre-populate the offset and float/locked options when adding a structure.

Syntax:

#pragma lockAt(offset)
#pragma floatAt(offset)

Where offset can be a decimal (e.g. 32) or hexadecimal value (e.g. 0x20).

Example:

 

struct LocalFileHeader
{

#pragma lockAt(0x00000010)

  char Signature[4]; // PK<0x03><0x04>

  WORD VersionNeededToExtract;

  WORD GeneralPurposeBitFlag;

  WORD CompressionMethod;

  DOSTIME LastModFileTime;

  DOSDATE LastModFileDate;

  DWORD Crc32;

  DWORD CompressedSize;

  DWORD UncompressedSize;

  WORD FileNameLength;

  WORD ExtraFieldLength;

};

More Information on Structure Definitions

Definition Overview, Data Types, Enumerated Types, Arrays, Strings, Bitfields, Expressions, Conditionals, Functions, Verification, Library Settings, Structure Settings, and Reserved Words and Symbols.