Worst-case scenario: the UEd Goblin wipes the map and burns down your house.

Difference between revisions of "Compiler issues"

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search
m (Parsing Issues: Swapped ...)
m (Parsing Issues)
Line 25: Line 25:
 
defaultproperties{
 
defaultproperties{
 
}</uscript>}}
 
}</uscript>}}
 +
 +
'''Switch''' ''Issues related to the [[switch]] block'' when attempting to access DefaultProperties from a static function.
 +
<br>
 +
:Using the syntax Default.Identifier (to resolve a DefaultProperties reference from a static function) within a [[switch]] block confuses the compiler, which assumes the script has an error, and suggests 'default:', as in ''the default case'' for a switch statement.  The error message is ''Error, Missing ':' in 'Default''.
 +
 +
{{CorrectWrong|<uscript>
 +
// A workaround is necessary.
 +
// Example using the class name directly..
 +
case 1:
 +
  Class'GameMessage'.Static.CallMe ();
 +
  break;
 +
// ..or an if-else block to replace the switch-case statement..
 +
// ..or a local proxy variable:
 +
static function Test (int Index)
 +
{
 +
  local class<LocalMessage> ClassNameWorkaround;
 +
  ClassNameWorkaround = Default.ClassName;
 +
  // ...
 +
    case 1:
 +
      ClassNameWorkaround.Static.CallMe ();
 +
      break;
 +
// ...
 +
}
 +
</uscript>|<uscript>
 +
var class<LocalMessage> ClassName;
 +
 +
static function Test (int Index)
 +
{
 +
  switch (Index)
 +
  {
 +
    case 1:
 +
      Default.ClassName.Static.CallMe ();
 +
      break;
 +
 +
    default:
 +
      break;
 +
  }
 +
}
 +
 +
DefaultProperties
 +
{
 +
  ClassName = Class'GameMessage'
 +
}
 +
</uscript>}}

Revision as of 19:22, 12 November 2011

Like any other compiler there are issues with the parsing therefor this page exists to mention those common issues and how to get around them.

Parsing Issues

Comment Issues related to the comments

Having an end of multi-line comment proceeded by a line comment on the same line.
Correct and Wrong example

DefaultProperties Issues related to the defaultproperties block

Placing a { on the same line of the defaultproperties declaration will cause the parser to skip the defaultproperties block thus :all of your default values will not be compiled, to get around this is easy just place the { on the next line!.
Correct and Wrong example

Switch Issues related to the switch block when attempting to access DefaultProperties from a static function.

Using the syntax Default.Identifier (to resolve a DefaultProperties reference from a static function) within a switch block confuses the compiler, which assumes the script has an error, and suggests 'default:', as in the default case for a switch statement. The error message is Error, Missing ':' in 'Default.
Correct and Wrong example