blob: d26f326182629047c5b621100cedd9bab5e53768 [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.
27
28 rtt_checks: runtime checks during execution of this program will be
29 enabled. The interpreter will check for correct datatypes of
30 arguments on function calls. (Later it will include checks
31 upon assignments.)
32 Don't confuse this with strong/strict_types, they only
33 check at compile time.
34 strong_types/strict_types is seriously recommended.
35 This pragma implicitly enables save_types as well.
36 no_rtt_checks: disable runtime type checks for this program (default).
37
38 pedantic: Certain warnings are treated as errors:
39 - failure to pass enough arguments to simul efuns
40 sloppy: Turns off pedantic (the default).
41
42 range_check: Use of questionable ranges (ranges of negative sizes,
43 or with bounds beyond the array's size) cause a runtime
44 warning.
45 no_range_check: Turns off range_check (the default).
46
47 warn_deprecated: Use of deprecated efuns or indexing operations
48 causes the compiler to issue a warning (the default).
49 no_warn_deprecated: Turns off warn_deprecated.
50
51 warn_empty_casts: A cast of a value to its own type generates
52 a warning (the default). Exception are casts to type
53 'mixed'.
54 no_warn_empty_casts: Turns off warn_empty_casts.
55
56 warn_missing_return: Warn if a value-returning function is missing
57 a return statement (the default). If possible, the driver
58 will try to detect this at compile time; otherwise a runtime
59 warning will be generated when the function is executed.
60 The check applies only to functions with a declared return
61 type other than 'void'.
62 no_warn_missing_return: Turn off warn_missing_return.
63
64 warn_function_inconsistent: If an inherited function is
65 overloaded with inconsistent return types or arguments,
66 a warning is generated; or if pragma_pedantic is in effect,
67 an error. By default this is active.
68 no_warn_function_inconsistent: An inherited function can
69 be overloaded with inconsistent return types or arguments,
70 as long as pragma_pedantic is not in effect.
71
72 This pragma is meant to easen the adaption of legacy
73 mudlib code - in general one should fix the warnings,
74 not turn them off.
75
76 When an object is compiled with type testing (#pragma
77 strict_types), all types are saved of the arguments for that
78 function during compilation. If the #pragma save_types is
79 specified, then the types are saved even after compilation, to
80 be used when the object is inherited.
81
82 The following two pragmas are available if the driver was
83 compiled with DEBUG and TRACE_CODE options:
84
85 set_code_window: Sets an offset to the current program writing
86 position. Use this BEFORE a piece of code where you
87 want to check to what bytecodes it is compiled.
88 show_code_window: shows some bytes starting at or near the
89 last point set_code_window was called.
90
91EXAMPLES
92 #pragma strict_types
93 #pragma no_clone, no_inherit
94
95HISTORY
96 LDMud 3.2.7 added local_scopes, no_local_scopes, no_clone
97 and no_inherit.
98 LDMud 3.2.8 added weak_types, pedantic and sloppy.
99 LDMud 3.2.9 allowed to specify multiple pragmas in one directive.
100 LDMud 3.2.9 added (no_)warn_deprecated.
101 LDMud 3.2.10 added (no_)warn_empty_casts.
102 Starting with LDMud 3.2.10, #pragma xxx_types in an included file are
103 no longer valid only until the end of the file, but remain active
104 when processing returns to the including file.
105 LDMud 3.2.11 added (no_)warn_function_inconsistent.
106 LDMud 3.3.378 added init_variables, share_variables.
107 LDMud 3.3.357 added (no_)warn_missing_return.
108 LDMud 3.3.646 added (no_)range_check.
109 LDMud 3.5.0 removed combine_strings and no_combine_strings.
110 LDMud 3.5.0 removed local_scopes and no_local_scopes.
111 LDMud 3.5.0 removed verbose_errors (making its behaviour mandatory).
112 LDMud 3.5.0 enabled warn_deprecated by default.
113
114SEE ALSO
115 inheritance(LPC), initialisation(LPC), objects(C),
116 operators(LPC)