3 It is possible that at some point we decide to switch QC-compiler which requires some changes to the code.
5 *For more information see* http://dev.xonotic.org/projects/bocc
9 In fteqcc there are some ambiguities regarding fieldpointers, function pointers, and field-return-types etc.
10 A clean syntax is needed, the current implementation uses the following:
12 |_.definition|_.meaning|
13 |<code>float foo</code>| global variable|
14 |<code>float .foo</code>| entity field|
15 |<code>.float foo</code>| fieldpointer|
16 |<code>.float .foo</code>| entity field of type fieldpointer|
17 |<code>float foo(void)</code>| function|
18 |<code>float foo*(void)</code>| function pointer|
19 |<code>.float foo(void)</code>| function returning a fieldpointer .float|
20 |<code>.float foo*(void)</code>| function pointer, returning a fieldpointer .float|
21 |<code>float .foo(void)</code>| entity field of type function returning float|
22 |<code>.float .foo(void)</code>| entity field of type function returning fieldpointer|
24 h2. Function definitions:
26 The old-style QC way of defining functions will not be supported, so
27 <pre>void(float x) something = { ... }</pre>
29 <pre>void something(float x) { ... }</pre>
30 which is the most common way to define functions in the xonotic code already anyway.
35 <pre>float x = 3</pre>
36 does what the first instinct tells you: it creates a global with the initial value 3. Contrary to old QC, where it created a constant.
37 To create a constant use:
38 <pre>const float x = 3</pre>
40 h2. Extendable functions:
42 Since menuQC has some funny macro: ACCUMULATE_FUNCTIONS, it seemed like a nice syntactical sugar to allow the following:
44 <pre>float myfunc() extendable
65 h2. Variadic parameters (do not use yet)
67 (This might get changed to be more flexible so do not rely on this syntax...)
69 Another "enhancement" is the possibility to have functions with variadic parameter lists. However, the only way to sanely access them (until pointers are allowed) is via a recursive way.
70 Here's an example that assumes float parameters and prints them one after the other:
71 <pre>void printfloats(float count, float first, ...)
73 if (count <= 0) // if there are no parameters, return
75 if (count == 1) { // If there's one parameter, print it, plus a new-line
76 print(strcat(ftos(first), "\n"));
79 // Otherwise we have multiple parameters left, so print the float, and add a comma
80 print(strcat(ftos(first), ", "));
81 myprint(count-1, ...);
83 So <code>myprint(4, 1, 2, 3, 4)</code> would print <code>"1, 2, 3, 4\n"</code>