Share via


Syntax for @dll.struct

The @dll.struct directive is placed just above the class declaration. The syntax of @dll.struct is:

  /**@dll.struct(<LinkTypeModifier>,<pack=n>)*/
  ...class declaration...;

LinkTypeModifier tells the compiler whether fields of type String and char represent ANSI or Unicode characters in native format. LinkTypeModifier can be ansi, unicode, or auto. If you do not specify LinkTypeModifier, ansi is used by default. See How the VM Chooses Between ANSI and Unicode to help you learn more about the values to use for LinkTypeModifier.

You can also specify pack=n to tell the compiler to set the packing size of the structure to either 1, 2, 4, or 8, depending on the value you specify for n. If you omit the pack=n modifier, the packing size is set to 8 by default. See Structure Packing for more information on setting the packing size.

Within the class declaration, you need to supply fields whose Java types map to the types of the fields in the native structure, in the order they occur in the native structure. See Correspondence Between Types Inside Structures for information about choosing the data types of the fields.

The following table describes the syntax for several situations in which you might use the @dll.struct directive.

Situation Required Syntax Explanation
Declare a structure
/**@dll.struct()*/
When you do not specify LinkTypeModifier, char or String fields are assumed to represent ANSI characters.
Set a structure's packing size
/**@dll.struct(pack=n)*/
n can be 1,2,4, or 8.
Declare a structure that has a field of type char
/**@dll.struct(ansi)*/
The character field represents an ANSI character.
Declare a structure with a field of type string and set the packing size
/**@dll.struct(unicode,pack=n)*/
The String fields will be in Unicode format, and the packing size is set to 1,2,4, or 8, depending on the value of n.