4 It is possible that at some point we decide to switch QC-compiler which requires some changes to the code.
6 ~~For more information see http://dev.xonotic.org/projects/bocc~~
8 (Update: Blub's bocc compiler didn't make it, but someone else came along, both devs [joined forces](https://github.com/graphitemaster/gmqcc/graphs/contributors) and brought us [GMQCC](https://graphitemaster.github.io/gmqcc/doc.html).
9 This is now the QuakeC compiler used by the Xonotic project.)
14 In fteqcc there are some ambiguities regarding fieldpointers, function pointers, and field-return-types etc.
15 A clean syntax is needed, the current implementation uses the following:
19 |`float foo`|global variable|
20 |`float .foo`|entity field|
21 |`.float foo`|fieldpointer|
22 |`.float .foo`|entity field of type fieldpointer|
23 |`float foo(void)`|function|
24 |`float foo*(void)`|function pointer|
25 |`.float foo(void)`|function returning a fieldpointer .float|
26 |`.float foo*(void)`|function pointer, returning a fieldpointer .float|
27 |`float .foo(void)`|entity field of type function returning float|
28 |`.float .foo(void)`|entity field of type function returning fieldpointer|
33 The old-style QC way of defining functions will not be supported, so
35 void(float x) something = { ... }
39 void something(float x) { ... }
41 which is the most common way to define functions in the xonotic code already anyway.
50 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.
51 To create a constant use:
58 Since menuQC has some funny macro: ACCUMULATE\_FUNCTIONS, it seemed like a nice syntactical sugar to allow the following:
60 float myfunc() extendable
80 Variadic parameters (do not use yet)
81 ------------------------------------
83 (This might get changed to be more flexible so do not rely on this syntax…)
85 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.
86 Here’s an example that assumes float parameters and prints them one after the other:
88 void printfloats(float count, float first, ...)
90 if (count <= 0) // if there are no parameters, return
92 if (count == 1) { // If there's one parameter, print it, plus a new-line
93 print(strcat(ftos(first), "\n"));
96 // Otherwise we have multiple parameters left, so print the float, and add a comma
97 print(strcat(ftos(first), ", "));
98 myprint(count-1, ...);
101 So `myprint(4, 1, 2, 3, 4)` would print "1, 2, 3, 4\\n"