Incompatibilities with ACS - DavidPH/GDCC GitHub Wiki
While GDCC's ACS front will generally be compatible with code written for ACC, there are some exceptions.
String type
The str
type in ACC is effectively an alias to int
(as are all other types). In GDCC's ACS, the str
type is incompatible and not interchangeable with int
. A str
value can't be assigned to int
, and an int
can't be assigned to str
. str
can't use any of the arithmetic operators. The equal ==
and not equal !=
operators behave identically to ACS (but only work when both values are str
).
str
can be converted to bool
, and is equivalent to str != 0
. 0
in a str
context is effectively like C's NULL
and is perfectly legal in assignment and comparison operations.
Forward declarations
In ACC, functions and variables can be used before they're defined. In GDCC, this results in a warning for functions but allows an implicit declaration, being the call (and if there's extra or fewer parameters in this implicit declaration or a type mismatch, there could be any amount of issues ranging from script termination, game crash or unintended behavior). To remove this risk and get rid of the warning, forward declarations must be used as in C. These are identical to regular function definitions, but it stops at the function signature and ends with a semicolon:
function void SampleForwardDeclaration (void);
Here's a more in-depth example:
function void ForwardDeclFunc (int test1, str test2);
Script "test" OPEN
{
// Wrong types of arguments. This will error out during compilation since there's a proper forward declaration.
//ForwardDeclFunc("foo", 10);
// Correct types, this will work without any warnings or bugs.
ForwardDeclFunc(10, "foo");
// Wrong amount of arguments, this will be compiled with a warning and will very likely cause a crash in-game.
// Without a forward declaration, the compiler doesn't know the proper arguments the function should (or shouldn't) take.
NotForwardDeclFunc(5, 2, 20);
// Correct amount of arguments. Again, without a forward declaration, the compiler doesn't know the proper arguments
// so this will be compiled with a warning. Likely won't cause any issues in-game.
NotForwardDeclFunc();
}
function void NotForwardDeclFunc (void)
{
}
function void ForwardDeclFunc (int test1, str test2)
{
}
Technically speaking, this isn't an incompatibility per se. If the code compiles fine in ACC, it's likely it'll compile and work fine in GDCC-ACC. But it does pose an extra risk not found in ACC, and should be properly taken care of.