User Tools

Site Tools


data_pragmas_1.htm
Navigation:  Advanced Topics > Legacy Project System Reference >====== Data #pragmas ====== Previous pageReturn to chapter overviewNext page

#pragmas with the class name data affect data segmentation, data pointers and all aspects of data layout. The current settings of the data #pragmas at the point of a variable's declaration will affect the way in which it is accessed.

The following data #pragmas are available:

#pragma data(c_far_ext ⇒ on | off)

#pragma data(class_hierarchy ⇒ on | off )

#pragma data(compatible_class ⇒ on | off)

#pragma data(const_assign ⇒ on | off )

#pragma data(const_in_code ⇒ on | off)

#pragma data(cpp_compatible_class ⇒ on | off )

#pragma data(ds_dynamic ⇒ on | off )

#pragma data(ext_record ⇒ on | off )

#pragma data(far_ext ⇒ on | off )

#pragma data(heap_size ⇒ Number)

#pragma data(near_ptr ⇒ on | off)

#pragma data(packed ⇒ on | off )

#pragma data(seg_name ⇒ identifier)

#pragma data(stack_size ⇒ Number)

#pragma data(threshold ⇒ Number)

#pragma data(var_enum_size ⇒ on | off)

#pragma data(volatile ⇒ on | off)

#pragma data(volatile_variant ⇒ on | off )

NoteBox.jpg

A pragma can be used in the Project language, C++ code, Modula-2 code, or Clarion code. Some only work in certain places. A 'P' to the right of the pragma indicates it can be used in the Project language, a 'C' indicates it can be used in C++ code, a 'M' indicates it can be used in Modula-2 code, and a 'W' indicates that it can be used in Clarion code (CLW files).

#pragma data(seg_name ⇒ identifier)   cpmw

The #pragma data(seg_3name⇒xxx) specifies that the compiler should place global initialized data objects in a segment named xxx_DATA, and global uninitialized data objects in a segment named xxx_BSS. These both have group name xxx and are in the FAR_DATA class. If the size of a data object is larger than the global data threshold, the compiler places the object in a separate segment.

The following example makes the names of the default segments: MYDATA_DATA and MYDATA_BSS. These segments are in group MYDATA and have class FAR_DATA:

#pragma data(seg_name ⇒ MYDATA)

You can also specify null, to indicate the names _BSS and _DATA. The default value is null in all models except for extra large and multi-thread. For example:

#pragma data(seg_name ⇒ null)

#pragma data(far_ext ⇒ on | off )    cpw

When on, the code generator does not assume that external variables are in the segment specified by the segment #pragma. The #pragma defaults to on. For example:

#pragma(seg_name⇒MYDATA, far_ext⇒off)

makes the name of the default segments MYDATA_DATA and MYDATA_BSS in group MYDATA. The compiler assumes external data objects to be in the same segment.

#pragma data(c_far_ext ⇒ on | off)    pm

When on, the code generator does not assume that external variables are in the segment specified by the seg_name #pragma. The #pragma defaults to off in all memory models. For example:

(*# data(seg_name ⇒ MYDATA, c_far_ext ⇒ off ) *)

makes the name of the default segments MYDATA_DATA and MYDATA_BSS in group MYDATA. This #pragma is not particularly useful in Modula-2 except for interfacing to C.

#pragma data(near_ptr ⇒ on | off)    cm

Specifies whether data pointers are near or far. This #pragma also affects pointers generated by the & operator and by implicit array to pointer conversions in C and C++. For example:

#pragma data(near_ptr ⇒ on)

makes data pointers near.

#pragma data(volatile ⇒ on | off)    m

Variables declared when this #pragma is set to on are considered to be volatile, and will always be kept in memory, rather than being kept in registers across statements.

The default setting is off. This #pragma is not allowed in a project file, and is not available for C and C++, where the volatile keyword should be used.

#pragma data(volatile_variant ⇒ on | off )   m

The effect is as for #pragma data(volatile), but applies to variables of variant record types only. The default setting is off.

#pragma data(ext_record ⇒ on | off )    pm

Normally SoftVelocity does not allow two fields in different alternatives of a variant record to have the same name. Using this #pragma:

(*# data( ext_record ⇒ on) *)

will allow you to use the same name in different alternatives, if the fields are located at the same offset in the variant record and they have the same data type.

The default setting is off.

#pragma data(var_enum_size ⇒ on | off)   pm

Enumeration constants with less than 256 alternative values are normally stored in one byte. Switching this option off:

(*# data( var_enum_size ⇒ off) *)

will force the compiler to store them as two-byte quantities. This is particularly useful for interfacing to third-party libraries and operating system calls that expect a word value. Without this #pragma the enumeration would be byte rather than word size.

The default setting is on.

#pragma data(stack_size ⇒ Number)   cmw

Specifies the size of the stack. You must place this #pragma in the file containing the main procedure (the main module in Modula-2). If the stack size cannot be set to the specified size, the compiler uses the largest possible size. The default size is 16K bytes. For example:

#pragma data(stack_size ⇒ 0x6000)

main()

{

/* statements */

}

makes the size of the run-time stack 0x6000 bytes (24K).

#pragma data(packed ⇒ on | off )    pm

This #pragma controls whether record fields are packed at bit level. The default setting is off.

#pragma data(const_in_code ⇒ on | off)   pw

This #pragma controls whether constants are put in to a code or data segment. The default setting is on.

#pragma data(class_hierarchy ⇒ on | off )   pm

This #pragma controls whether information about class hierarchies is included in the class descriptor (method table). The information is used by the IS operator and TypeGuards with check on. The default setting is on.

#pragma data(cpp_compatible_class ⇒ on | off )  pm

This #pragma controls whether the compiler includes extra information in class descriptors to provide compatibility with C. The default setting is off.

#pragma data(compatible_class ⇒ on | off)   cp

This #pragma controls whether the compiler includes the correct information in class descriptors to provide compatibility with Modula-2. The default setting is off.

#pragma data(threshold ⇒ Number)    cpmw

This #pragma sets the global data threshold. This determines at what size a data object is placed in a segment of its own. The default setting is 10000 bytes.

#pragma data(const_assign ⇒ on | off )   pm

This #pragma controls whether it is possible to assign to a structured constant. The default setting is off.

NoteBox.jpg If const_in_code⇒on is specified, assignments to constants will result in protection violations.

data_pragmas_1.htm.txt · Last modified: 2021/04/15 15:57 by 127.0.0.1