User Tools

Site Tools


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

#pragmas with the class name module control options that apply to an entire source file or module. These #pragmas should be specified at the top of any source files to which they apply, or in the project file.

The following module #pragmas are available:

#pragma module(implementation ⇒ on | off )

#pragma module(init_code ⇒ on | off )

#pragma module(init_prio ⇒ Number)

#pragma module(smart_link ⇒ 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 module(init_code ⇒ on | off )   pm

When on, it implies that the module contains initialization code to be run when the program is loaded and before the main module is executed. Switching the option off is useful for modules written in other languages, as it will stop the linker warning of undefined symbols:

(*# module( init_code ⇒ off ) *)

NoteBox.jpg If an implementation module sets this #pragma off, then there is a knock-on effect, i.e., all imported modules must also have init_code set to off.

The default setting is on.

#pragma module(implementation ⇒ on | off )  pm

This #pragma specifies whether or not a definition file (.DEF or .ITF) has a corresponding object file. It should be turned off if the definition file defines interfaces to routines in a different language, to prevent the Project System from attempting to remake the corresponding object file. The default is on.

This #pragma can also be used in the implementation part of a module, before any module source code. In this case it overrides the default naming of the associated object file. Normally the name of the .OBJ file corresponding to a module is taken from the module name. When this #pragma is set off, the object filename will be taken from the filename, not the module name.

#pragma module(smart_link ⇒ on | off)   cpm

Setting this #pragma to off disables the smart linking feature, to the extent that either all or none of the objects in each segment from a compile will be included in a link. This may result in quicker linking, and also may allow other linkers (such as Microsoft) to be used. (There are many potential problems with trying to use a non-SoftVelocity linker, and it is definitely not recommended). The default setting is on.

#pragma module(init_prio ⇒ Number)   cpw

This #pragma is available under C only. It defines a priority for the initialization code for static objects. Normally the initialization order is undefined between files, but this #pragma allows you to control the initialization order in that files with higher priority are initialized before modules with lower priority. The number must be a value between 0 and 32. The default value is 16, and the C library uses values between 25 and 32 (it is therefore not recommended to use values in this range, otherwise part of the library may not have initialized before user code is executed).

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