编译错误

第二种类型的错误是编译器错误。当游戏遇到语法检查器可能无法检测到的错误时,就会发生编译器错误-很容易忘记声明变量或错误地将字符串输入为真实的,例如-或者当错误与您如何从目标平台的平台首选项设置编译工具有关时。这些错误将被GameMaker捕获当游戏正在编译时,此信息也将显示在编译器错误输出中,如下所示:

Compile Errors

注意 这些错误通常不会弹出一个窗口,只会在编译器输出中显示 "Build Failed"。如果弹出一个窗口,则通常是运行程序错误, 此处 对此进行解释。

编译器错误消息都将遵循相同的格式:

[object] - [event] - [Line Number]: [error string]

如果在脚本中发现错误,那么它将简单地:

[script] - [Line Number]: [error string]

然后,您可以双击Icon LMB任何编译器错误条目,以在标记为给出错误的位置打开给定资产,然后您可以使用消息中包含的信息来精确定位对象或脚本中发生错误的位置。然而,有时这些错误看起来有点神秘,所以下面你可以找到所有错误的完整列表和它们的含义的简要解释:

 

错误(Error)描述

其他

No program to compileA previous compile error has caused the compiler parse tree to not be created and thus the compiler has no program data to compile
Fatal Error while compiling [name] - bailing details belowThis message simply means that some error has been discovered but the compiler cannot place what or where (if this happens consistently you may wish to contact support and supply the details that the compiler output window shows)
Recursive macro expansion is not supportedYou have used recursive macros that refer to each other and constantly expand
Unable to find TextureGroup [group]This error is usually only found from trying to run a malformed project file (if this happens consistently you may wish to contact support and supply the details that the compiler output window shows)
Wrong to convert [value] to numberYou have tried to convert the given value, for example a string, into a number
Division by 0You have tried to divide a value by 0
Invalid object id [object ID] usedYou have tried to access an object using an ID value that is incorrect
Unclosed comment (/*) at end of scriptYou have created a script comment using
/* [comment] */
but have not supplied the closing comment tag
Invalid tokenYou have an invalid character in your game code, which can happen with foreign language characters or Unicode
Number [num] in incorrect formatThe given number - shown in the error - is not the correct format for the function or operation being performed, for example you supply an integer when a pointer is required
Unexpected EOF encounteredYou have reached the end of file unexpectedly while using the File Functions

字符串

Unable to Not a stringYou have tried to use "!" (not) on a string
Unable to Negate a stringYou have tried to negate a string, for example
string = -string

函数、函数和参数

Wrong number of arguments for function [function]You have supplied too many or too few arguments for the given function
Failed to parse action_execute_script() - incorrect number of arguments receivedThe GML Visual action Execute Script has too many or too few arguments for the given script being called
Unknown function [function] check to see if script is emptyA script or function has been called that the compiler does not recognise (this error is usually thrown by empty script asset references since the compiler will strip out these assets on compile)
Function [function] expects n arguments, a providedA function has been given the wrong number of arguments (n) when a certain number were expected (a)
Assignment of an empty value (function does not return anything?)You have tried to assign a return value from a function when that function returns nothing
Unable to find function [function]    You have called an unknown function
Calling a function that needs an instance and no instance is availableThe function or script being called is for acting on an instance, but at the time of running no instances exist
Calling a function that needs an other and no other is availableYou have used the keyword other outside of the Collision Event or outside of a with statement
Argument naming error, n arguments but no reference found to aYou have given a number of arguments to a script, but fail to reference one of them in the script, for example, your script takes three arguments but you only use arguments n and a
Cannot compare argumentsYou have tried to compare two different argument types, like a string and a real number
Unknown function or script [functions/script] The compiler does not recognise the function or script being called
Cannot use resource name [resource] as it is not being exportedYou have tried to access a resource that has not been flagged as part of the project for the platform being compiled to
Cannot use function/script name for a variable, using [functions/script]You have tried to use either a function name or a script name as a variable, for example:
string = "Hello World"
Cannot use an argument outside a script The built in argument variables can only be used inside a script but you have tried to use them elsewhere
No references to argument[num] but references argument[num]You are using a reference to an argument that does not exist but that could map to another argument
Incorrect number of arguments for accessorYou have supplied the wrong number of arguments when using an accessor
Wrong type of arguments for (one of the below):
/, div, mod, +, -, &&, ||, &, |, ^, <<, >>
You have supplied the wrong type of argument for the expression being evaluated

变量

Using uninitialized variable [var]You have tried to use the named variable before it has been initialised
Variable [var] is read-onlyYou have tried to change the named variable when it cannot be changed
Unable to find variable named [var]The named variable cannot be found in the current compile
Malformed variable referenceYou have tried to reference a variable in the wrong way
Trying to set a read only variable [var]You have tried to set a variable that is read only
Cannot re-declare a built in variableYou have tried to declare a local variable using the same name as one of the built in variables
Cannot use resource name for a variableYou have use the same name as a resource from the resource tree as a local variable
[Variable] is read-onlyYou have tried to use a variable that has been flagged as read only

常量

Cannot set a constant [constant] to a valueYou have tried to set a constant to a different value
Constant is invalid hereYou have tried to use a constant somewhere that is not valid for the code being run
Cannot assign to [var] - it's a constantYou have tried to assign a new value to the named constant

数组

Array index should not be negativeYou have tried to access, create, or set an array value using a negative array index

格式错误

Malformed Conditional operatorYou have used an erroneous conditional (ternary) operator or if statement, and not the format:
[condition] ? [expression1] : [expression2];
If requires a then statementYou have written an if statement and expression to evaluate, but not given any then part to run
malformed assignment statementIn the code you are using an assignment operator wrong
Malformed
if / repeat / while / do / for / with / switch / break / continue / exit
statement
The structure of the given statement is incorrect.
Malformed post inc or dec statementYou have tried to use [var]++ or [var]-- in an illegal way
Malformed pre inc or dec statementYou have tried to use ++[var] or --[var] in an illegal way
Malformed global gml_pragmaYou have created a wrong global string when using gml_pragma
Malformed PNGCrush gml_pragmaYou have created a wrong string command for PNGCrush when using gml_pragma
Malformed Texgroup.Scale gml_pragmaYou have create a wrong global string when using gml_pragma

Switch / Case

Default cannot be used multiple times in a switchIn your switch statement you have defined default: more than once
Clause expression type mismatch (clause expressions should all be the same type)In your switch you are checking for two different constant case types, for example a string in one case and an integer in another
Case argument should be a constantYou have tried to use a value that does not evaluate to a constant within one of your switch cases
Statement in a switch MUST appear after case or defaultYou have added a statement to a switch outside of either a case: or default: call
Duplicate case statement found / original hereYou have used the same case constant in two different places within a switch (note that the "original here" comment will be on another line and can be clicked to show the original case)

表达式

No return value from expression (does expression have a return value?)You have tried to assign a return value from an expression to a variable when the expression returns nothing
Expecting expression after the '.'You have used the point "." notation erroneously and not added an expression afterwords correctly
Unexpected symbol [symbol] in expressionThe expression uses a symbol that is not part of the accepted expression symbol set - the symbol in question will be shown

未知运算符

Unknown Pre operatorYou have tried to use a symbol as a pre-operator when that symbol is not permitted, for example **[var] or >>[var] - only ++ and -- are acceptable
Unknown Post operatorYou have tried to use a symbol as a post-operator when that symbol is not permitted, for example [var]** or [var]>> - only ++ and -- are acceptable
Unknown pragma [gml_pragma string]You have used a pragma string that is unknown to the compiler
Unknown unary operatorYou have tried to use an unknown symbol as a unary operator
Unknown binary operatorYou have tried to use an unknown symbol as a binary operator
Unknown operator [operator]You have tried to use an unknown symbol as an operator (the symbol will be shown in the error)

Break / Continue

Break used without contextYou have not used break within a switch or a loop or any other permitted structure
Continue used without contextYou have not used continue within the correct context
continue statement is not allowed at this pointYou have used continue within a apart of your code where it is not permitted

枚举

enum num is invalidThe enum number is invalid for the enum
malformed enumYou have not created the enum correctly
enum [enum] has already been definedYou have tried to define an enum using the same name as another previously defined
malformed enum entryThe enum has an invalid entry
enum expression must be an integer constantThe enum entry does not evaluate as an integer constant
enum reference [key] does not exist in [enum]You have tried to reference an enum entry using a key that has not previously been defined for that enum

预期符号/值

Symbol ( expected
Symbol ) expected
Symbol , or ) expected
Symbol { expected
Symbol } expected
Symbol , or } expected
Symbol : expected
Symbol ; expected
Symbol [ expected
symbol ] expected
Symbol , or ] expected
You have not used a required symbol when writing your code
Expected id or stringYou have used a value that is not either a layer ID or a layer name - as a string - in one of the Layer functions
keyword Until expectedYou have created a do... until loop but neglected to supply an until expression
Function name expectedYou have used something other than a function name in your code where a function should go
variable name expectedYou have supplied a name that is not a variable name where one is expected
Assignment operator expectedYou have created an assignment which expects an operator but none has been supplied

Android独有

Android ARM ToolChain directory [dir] does not existThe link given in the Android Preferences for the ARM toolchain is incorrect and does not exist.
Android MIPS ToolChain directory [dir] does not existThe link given in the Android Preferences for the MIPS toolchain is incorrect and does not exist.
Android x86 ToolChain directory [dir] does not existThe link given in the Android Preferences for the x86 toolchain is incorrect and does not exist.
Android NDK directory [dir] does not existThe link given in the Android Preferences for the Android NDK is incorrect and does not exist.

Windows独有

Configuration Problem : Windows Visual Studio Path needs to be set to point to Visual Studio (.bat) batch file.The link given in the Windows Preferences for the Visual Studio (.bat) batch file is incorrect and does not exist.