source: project/chicken/branches/release/manual/Declarations @ 7276

Last change on this file since 7276 was 7276, checked in by felix winkelmann, 12 years ago

merged trunk

File size: 8.5 KB
Line 
1[[tags: manual]]
2[[toc:]]
3
4
5== Declarations
6
7
8=== declare
9
10 [syntax] (declare DECLSPEC ...)
11
12Process declaration specifiers. Declarations always override
13any command-line settings.  Declarations are valid for the whole
14compilation-unit (source file), the position of the declaration in
15the source file can be arbitrary. Declarations are ignored in the interpreter
16but not in code evaluated at compile-time (by {{eval-when}} or in
17syntax extensions loaded via {{require-extension}} or {{require-for-syntax}}.
18{{DECLSPEC}} may be any of the following:
19
20
21=== always-bound
22
23 [declaration specifier] (always-bound SYMBOL ...)
24
25Declares that the given variables are always bound and
26accesses to those have not to be checked.
27
28
29=== block
30
31 [declaration specifier] (block)
32
33Assume global variables are never redefined. This is the same as
34specifying the {{-block}} option.
35
36
37=== block-global
38=== hide
39
40 [declaration specifier] (block-global SYMBOL ...)
41 [declaration specifier] (hide SYMBOL ...)
42
43Declares that the toplevel bindings for {{SYMBOL ...}}
44should not be accessible from code in other compilation units or by
45{{eval}}. Access to toplevel bindings declared as block global is
46also more efficient.
47
48
49=== bound-to-procedure
50
51 [declaration specifier] (bound-to-procedure SYMBOL ...)
52
53Declares that the given identifiers are always bound to procedure values.
54
55
56=== c-options
57
58 [declaration specifier] (c-options STRING ...)
59
60Declares additional C/C++ compiler options that are to be passed to the subsequent compilation pass
61that translates C to machine code. This declaration will only work if the source file is compiled
62with the {{csc}} compiler driver.
63
64
65=== check-c-syntax
66
67 [declaration specifier] (check-c-syntax)
68 [declaration specifier] (not check-c-syntax)
69
70Enables or disables syntax-checking of embedded C/C++ code fragments. Checking C syntax is the default.
71
72
73=== constant
74
75 [declaration specifier] (constant SYMBOL ...)
76
77Declares the procedures with the names {{SYMBOL ...}} as constant, that is, as not having any
78side effects. This can help the compiler to remove non-side-effecting expressions.
79
80
81=== export
82
83 [declaration specifier] (export SYMBOL ...)
84
85The opposite of {{hide}}. All given identifiers will be exported and all toplevel variables
86not listed will be hidden and not be accessible outside of this compilation unit.
87
88
89=== emit-exports
90
91 [declaration specifier] (emit-exports STRING)
92
93Write exported toplevel variables to file with name {{STRING}}.
94
95
96=== emit-external-prototypes-first
97
98 [declaration specifier] (emit-external-prototypes-first)
99
100Emit prototypes for callbacks defined with {{define-external}} before any
101other foreign declarations. Equivalent to giving the {{-emit-external-prototypes-first}}
102option to the compiler.
103
104
105=== disable-interrupts
106
107 [declaration specifier] (disable-interrupts)
108 [declaration specifier] (not interrupts-enabled)
109
110Disable timer-interrupts checks in the compiled program. Threads can
111not be preempted in main- or library-units that contain this declaration.
112
113
114=== disable-warning
115
116 [declaration specifier] (disable-warning CLASS ...)
117
118Disable warnings of type {{CLASS ...}} (equivalent to the {{-disable-warning CLASS}}
119compiler option).
120
121
122=== import
123
124 [declaration specifier] (import SYMBOL-OR-STRING ...)
125
126Adds new imports to the list of externally available toplevel variables. Arguments to this declaration
127may be either strings (designating {{.exports}} files, without the file-extension) or symbols
128which directly designate imported variables.
129
130
131=== inline
132
133 [declaration specifier] (inline)
134 [declaration specifier] (not inline)
135 [declaration specifier] (inline IDENTIFIER ...)
136 [declaration specifier] (not inline IDENTIFIER ...)
137
138If given without an identifier-list, inlining of known procedures is enabled (this is equivalent to the {{-inline}}
139compiler option). When an identifier-list is given, then inlining is enabled only for the specified global procedures.
140The negated forms {{(not inline)}} and {{(not inline IDENTIFIER)}} disable global inlining, or inlining for
141the given global procedures only, respectively.
142
143
144=== inline-limit
145
146 [declaration specifier] (inline-limit THRESHOLD)
147
148Sets the maximum size of procedures which may potentially be inlined. The default threshold is {{10}}.
149
150
151=== interrupts-enabled
152
153 [declaration specifier] (interrupts-enabled)
154
155Enable timer-interrupts checks in the compiled program (the default).
156
157
158=== keep-shadowed-macros
159
160 [declaration specifier] (keep-shadowed-macros)
161
162Normally, when a toplevel variable is assigned or defined that has the same name as a macro, the macro-definition
163will be removed (in addition to showing a warning). This declaration will disable the removal of the macro.
164
165
166=== lambda-lift
167
168 [declaration specifier] (lambda-lift)
169
170Enables lambda-lifting (equivalent to the {{-lambda-lift}} option).
171
172
173=== link-options
174
175 [declaration specifier] (link-options STRING ...)
176
177Declares additional linker compiler options that are to be passed to the subsequent compilation pass
178that links the generated code into an executable or library.
179This declaration will only work if the source file is compiled
180with the {{csc}} compiler driver.
181
182
183=== no-argc-checks
184
185 [declaration specifier] (no-argc-checks)
186
187Disables argument count checking.
188
189
190=== no-bound-checks
191
192 [declaration specifier] (no-bound-checks)
193
194Disables the bound-checking of toplevel bindings.
195
196
197=== no-procedure-checks
198
199 [declaration specifier] (no-procedure-checks)
200
201Disables checking of values in operator position for being of procedure type.
202
203
204=== post-process
205
206 [declaration specifier] (post-process STRING ...)
207
208Arranges for the shell commands {{STRING ...}} to be invoked after the current
209file has been translated to C. Any occurrences of the substring {{$@@}} in the
210strings given for this declaration will be replaced by the pathname of the currently
211compiled file, without the file-extension.
212This declaration will only work if the source file is compiled
213with the {{csc}} compiler driver.
214
215
216=== number-type
217=== fixnum-arithmetic
218
219 [declaration specifier] ([number-type] TYPE)
220 [declaration specifier] (fixnum-arithmetic)
221
222Declares that only numbers of the given type are used. {{TYPE}}
223may be {{fixnum}} or {{generic}} (which is
224the default).
225
226
227=== run-time-macros
228
229 [declaration specifier] (run-time-macros)
230
231Equivalent to the compiler option of the same name - macros defined in the compiled code are also made available at
232runtime.
233
234
235=== standard-bindings
236
237 [declaration specifier] (standard-bindings SYMBOL ...)
238 [declaration specifier] (not standard-bindings SYMBOL ...)
239
240Declares that all given standard procedures (or all if no symbols are
241specified) are never globally redefined.  If {{not}} is specified,
242then all but the given standard bindings are assumed to be never
243redefined.
244
245
246=== extended-bindings
247
248 [declaration specifier] (extended-bindings SYMBOL ...)
249 [declaration specifier] (not extended-bindings SYMBOL ...)
250
251Declares that all given non-standard and CHICKEN-specific procedures (or all if no symbols are specified) are never globally redefined.
252If {{not}} is specified, then all but the given extended bindings
253are assumed to be never redefined.
254
255
256=== usual-integrations
257
258 [declaration specifier] (usual-integrations SYMBOL ...)
259 [declaration specifier] (not usual-integrations SYMBOL ...)
260
261Declares that all given standard and extended bindings (or all if no
262symbols are specified) are never globally redefined.  If {{not}}
263is specified, then all but the given standard and extended bindings are
264assumed to be never redefined. Note that this is the default behaviour,
265unless the {{-no-usual-integrations}} option has been given.
266
267
268=== unit
269
270 [declaration specifier] (unit SYMBOL)
271
272Specify compilation unit-name (if this is a library)
273
274
275=== unsafe
276
277 [declaration specifier] (unsafe)
278 [declaration specifier] (not safe)
279
280Do not generate safety-checks. This is the same as specifying the
281{{-unsafe}} option.  Also implies
282
283
284 (declare (no-bound-checks) (no-procedure-checks) (no-argc-checks))
285
286
287=== unused
288
289 [declaration specifier] (unused SYMBOL ...)
290
291Disables any warnings when the global variable {{SYMBOL}} is not defined but used,
292or defined but never used and not exported.
293
294
295=== uses
296
297 [declaration specifier] (uses SYMBOL ...)
298
299Gives a list of used library-units. Before the toplevel-expressions
300of the main-module are executed, all used units evaluate their
301toplevel-expressions in the order in which they appear in this
302declaration. If a library unit A uses another unit B, then B's toplevel
303expressions are evaluated before A's.  Furthermore, the used symbols
304are registered as features during compile-time, so {{cond-expand}}
305knows about them.
306
307Previous: [[Pattern matching]]
308
309Next: [[Parameters]]
Note: See TracBrowser for help on using the repository browser.