Skip to content
medimatrix edited this page Nov 21, 2014 · 7 revisions

gmqcc

What is gmqcc

gmqcc is a QC compiler written from scratch with a modern design to avoid the shortcomings of previous QC compilers such as fteqcc. Our ultimate goal is to provide full support for both id1 QC and fteqcc's dialect, as well as add our own, and provide a codebase suitable for further development. Future goals include for example to get rid of the need for prototyping of functions, in order to make QC even more newbie-friendly.

Why another QC Compiler?

qcc as well as most compilers based on it contain a bunch of bugs, many of which aren't easily fixable because the codebase is old and covered in dust. They still serve their purpose, but often enough compiler bugs have been hit for example in the Nexuiz or Xonotic gamecodes which required workarounds until someone managed to fix the compiler, which was often a pain to do.

What does QC look like?

QC mostly looks like C, but is far simpler and far less powerful. It has no pointers, no struct or union, no way to allocate raw data, and instead works on objects in the game called entity, which can be spawned and contain members defined in the QC source.

The only types in QC are entity, float, string, vector, and of course functions made using these.

Additionally, variables can also hold functions or entity-member-offsets, basically working like function-pointers or member-pointers.

.vector origin; // every entity has a position now
// additionally a global variable named 'origin' acts as a memberpointer
// as well as the global variables
// origin_x, origin_y and origin_z are member-pointers of type '.float'

entity self;    // there's a global variable of type entity named self

void() reset_self = {
    self.origin = '0 0 0';
};

void() raise = {
    self.origin_z = self.origin_z + 1; // vector-subelement access
};
Clone this wiki locally