ACC Incompatibility

From GDCC Wiki
Revision as of 15:40, 25 July 2017 by DavidPH (talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

While gdcc-acc is for the most part backwards-compatible with acc, there are a number of incompatibilities that will prevent some acc-centric code from compiling.

Incorrectly typed arrays

In gdcc-acc, incorrectly typed arrays (for example, an array of strings using the type 'int') are not allowed.

int my_array[2] = { "Hello", "World" };

To fix this, use the correct type, str.

Function prototypes

Like in acc, functions in gdcc-acc can be used before being declared. However, arguments will not have their types converted correctly.

script "forward_ref" (void)
    // Will log 0.25.

function void sample_function(fixed val)

The solution to this is to either move the function above its first usage in the code, or add a function prototype before it is used, such as the following:

function void sample_function(fixed val);

Script numbers

In gdcc-acc, a script number has to be an integer literal, not an expression. This applies even when using a macro.

#define ScriptFoo 1035
#define ScriptBuh ScriptFoo + 1

// OK
script ScriptFoo (void)

// ERROR: expected script-address got '('
// script ScriptBuh (void)
// {
// }

Builtin functions

Unlike acc, gdcc-acc does not predeclare builtin ACS functions. The "zcommon.acs" header must be included even to use functions like Delay or Print.

Extra keywords

In gdcc-acc, there are additional keywords, which cannot be used for object or function names.

As of v0.11.0, these are: enum, fixed, float, sizeof, and struct.