blob: 21d488122c5eea6fc1c406e0f8d8fc2db6607f44 [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001NAME
2 pragma
3
4DESCRIPTION
5 The preprocessor directive #pragma can be used to select
6 several compilation options. Multiple options can be selected
7 in one #pragma directive by separating them with commas.
8
9 no_clone: The blueprint object can't be cloned.
10 no_inherit: The program can't be inherited.
11 no_shadow: The program can't be shadowed (similar to declaring
12 all functions as 'nomask').
13
14 init_variables: Clone variables are initialized by __INIT().
15 share_variables: Clone variables are initialized from the
16 blueprint.
17
18 weak_types: no type checking (this is the default).
19 strict_types: all functions must be declared with argument
20 prototypes, and the return values of call_other() must
21 be casted.
22 strong_types: all functions must be declared with complete
23 types of return value and parameters.
24 save_types: the declaration data is kept after compilation and
25 checked at runtime. This is important for type-safe
26 inheritance.
Zesstra7ea4a032019-11-26 20:11:40 +010027 no_bytes_type: removes the keyword 'bytes', also 'string' then
28 denotes the type <string|bytes>.
29 bytes_type: reactivates the keyword 'bytes' and distinguishes
30 between the 'bytes' and 'string' type.
MG Mud User88f12472016-06-24 23:31:02 +020031
32 rtt_checks: runtime checks during execution of this program will be
Zesstra7ea4a032019-11-26 20:11:40 +010033 enabled. The interpreter will check for correct datatypes in
34 the following circumstances:
35 - arguments on function calls,
36 - return values of functions,
37 - assignment to variables,
38 - restoration of values to variables or struct members.
MG Mud User88f12472016-06-24 23:31:02 +020039 Don't confuse this with strong/strict_types, they only
40 check at compile time.
41 strong_types/strict_types is seriously recommended.
42 This pragma implicitly enables save_types as well.
Zesstra7ea4a032019-11-26 20:11:40 +010043 warn_rtt_checks: runtime checks are enabled, just like rtt_checks,
44 but errors will be shown as warnings only.
MG Mud User88f12472016-06-24 23:31:02 +020045 no_rtt_checks: disable runtime type checks for this program (default).
46
47 pedantic: Certain warnings are treated as errors:
Zesstra7ea4a032019-11-26 20:11:40 +010048 - failure to pass enough arguments to simul efuns
49 - type casts with no effect
50 - inconsistent declarations
51 - inconsistent overloads
52 - double inherits
MG Mud User88f12472016-06-24 23:31:02 +020053 sloppy: Turns off pedantic (the default).
54
55 range_check: Use of questionable ranges (ranges of negative sizes,
56 or with bounds beyond the array's size) cause a runtime
57 warning.
58 no_range_check: Turns off range_check (the default).
59
60 warn_deprecated: Use of deprecated efuns or indexing operations
61 causes the compiler to issue a warning (the default).
62 no_warn_deprecated: Turns off warn_deprecated.
63
64 warn_empty_casts: A cast of a value to its own type generates
Zesstra7ea4a032019-11-26 20:11:40 +010065 a warning. Also casting a value of mixed/unknown type or
66 casting to mixed will generate a warning (the default).
MG Mud User88f12472016-06-24 23:31:02 +020067 no_warn_empty_casts: Turns off warn_empty_casts.
68
69 warn_missing_return: Warn if a value-returning function is missing
70 a return statement (the default). If possible, the driver
71 will try to detect this at compile time; otherwise a runtime
72 warning will be generated when the function is executed.
73 The check applies only to functions with a declared return
74 type other than 'void'.
75 no_warn_missing_return: Turn off warn_missing_return.
76
77 warn_function_inconsistent: If an inherited function is
78 overloaded with inconsistent return types or arguments,
79 a warning is generated; or if pragma_pedantic is in effect,
80 an error. By default this is active.
81 no_warn_function_inconsistent: An inherited function can
82 be overloaded with inconsistent return types or arguments,
83 as long as pragma_pedantic is not in effect.
84
85 This pragma is meant to easen the adaption of legacy
86 mudlib code - in general one should fix the warnings,
87 not turn them off.
88
89 When an object is compiled with type testing (#pragma
90 strict_types), all types are saved of the arguments for that
91 function during compilation. If the #pragma save_types is
92 specified, then the types are saved even after compilation, to
93 be used when the object is inherited.
94
95 The following two pragmas are available if the driver was
96 compiled with DEBUG and TRACE_CODE options:
97
98 set_code_window: Sets an offset to the current program writing
99 position. Use this BEFORE a piece of code where you
100 want to check to what bytecodes it is compiled.
101 show_code_window: shows some bytes starting at or near the
102 last point set_code_window was called.
103
104EXAMPLES
105 #pragma strict_types
106 #pragma no_clone, no_inherit
107
108HISTORY
109 LDMud 3.2.7 added local_scopes, no_local_scopes, no_clone
110 and no_inherit.
111 LDMud 3.2.8 added weak_types, pedantic and sloppy.
112 LDMud 3.2.9 allowed to specify multiple pragmas in one directive.
113 LDMud 3.2.9 added (no_)warn_deprecated.
114 LDMud 3.2.10 added (no_)warn_empty_casts.
115 Starting with LDMud 3.2.10, #pragma xxx_types in an included file are
116 no longer valid only until the end of the file, but remain active
117 when processing returns to the including file.
118 LDMud 3.2.11 added (no_)warn_function_inconsistent.
119 LDMud 3.3.378 added init_variables, share_variables.
120 LDMud 3.3.357 added (no_)warn_missing_return.
121 LDMud 3.3.646 added (no_)range_check.
122 LDMud 3.5.0 removed combine_strings and no_combine_strings.
123 LDMud 3.5.0 removed local_scopes and no_local_scopes.
124 LDMud 3.5.0 removed verbose_errors (making its behaviour mandatory).
125 LDMud 3.5.0 enabled warn_deprecated by default.
126
127SEE ALSO
128 inheritance(LPC), initialisation(LPC), objects(C),
129 operators(LPC)