- Fixed some warnings flagged by GCC 4.1.1, which brings up an interesting

observation. The following code works with VC++ 2005. It aborts with GCC:
    FString str = "This is a string.";
    Printf ("%s\n", str);

SVN r408 (trunk)
This commit is contained in:
Randy Heit 2006-12-09 00:16:10 +00:00
parent 6f3a28e355
commit 41de448add
12 changed files with 130 additions and 101 deletions

View file

@ -749,7 +749,7 @@ public:
bool UpdateWaterLevel (fixed_t oldz); bool UpdateWaterLevel (fixed_t oldz);
FState *FindState (FName label) const; FState *FindState (FName label) const;
FState *FindState (int numnames, int first, ...) const; FState *FindState (int numnames, ...) const;
FState *FindState (int numnames, va_list arglist) const; FState *FindState (int numnames, va_list arglist) const;
bool HasSpecialDeathStates () const; bool HasSpecialDeathStates () const;

View file

@ -509,8 +509,7 @@ bool AActor::HasSpecialDeathStates () const
// //
//=========================================================================== //===========================================================================
FState *AActor::FindState (int numnames, int first, ...) const // The 'first' parameter is only here to FState *AActor::FindState (int numnames, ...) const
// disambiguate from the single parameter version
{ {
va_list arglist; va_list arglist;
va_start (arglist, numnames); va_start (arglist, numnames);

View file

@ -574,6 +574,12 @@ bool M_ReadIDAT (FileReader *file, BYTE *buffer, int width, int height, int pitc
initpass = true; initpass = true;
pass = interlace ? 0 : 7; pass = interlace ? 0 : 7;
// Silence GCC warnings. Due to initpass being true, these will be set
// before they're used, but it doesn't know that.
curr = prev = 0;
passwidth = passpitch = bytesPerRowIn = 0;
passbuff = 0;
while (err != Z_STREAM_END && pass < 8 - interlace) while (err != Z_STREAM_END && pass < 8 - interlace)
{ {
if (initpass) if (initpass)

View file

@ -4753,7 +4753,7 @@ void AActor::Crash()
if (DamageType != NAME_None) if (DamageType != NAME_None)
{ {
crashstate = GetClass()->ActorInfo->FindStateExact(2, NAME_Crash, DamageType); crashstate = GetClass()->ActorInfo->FindStateExact(2, NAME_Crash, int(DamageType));
} }
if (crashstate == NULL) if (crashstate == NULL)
{ {

View file

@ -376,6 +376,27 @@ static void ParseOuter ()
} }
} }
//==========================================================================
//
// SetSplashDefaults
//
//==========================================================================
static void SetSplashDefaults (FSplashDef *splashdef)
{
splashdef->SmallSplashSound =
splashdef->NormalSplashSound = 0;
splashdef->SmallSplash =
splashdef->SplashBase =
splashdef->SplashChunk = NULL;
splashdef->ChunkXVelShift =
splashdef->ChunkYVelShift =
splashdef->ChunkZVelShift = 8;
splashdef->ChunkBaseZVel = FRACUNIT;
splashdef->SmallSplashClip = 12*FRACUNIT;
splashdef->NoAlert = false;
}
//========================================================================== //==========================================================================
// //
// ParseSplash // ParseSplash
@ -395,6 +416,7 @@ void ParseSplash ()
if (splashnum < 0) if (splashnum < 0)
{ {
FSplashDef def; FSplashDef def;
SetSplashDefaults (&def);
def.Name = name; def.Name = name;
splashnum = (int)Splashes.Push (def); splashnum = (int)Splashes.Push (def);
isnew = true; isnew = true;
@ -402,19 +424,16 @@ void ParseSplash ()
splashdef = &Splashes[splashnum]; splashdef = &Splashes[splashnum];
SC_MustGetString (); SC_MustGetString ();
if (!SC_Compare ("modify") || (SC_MustGetString(), isnew)) if (!SC_Compare ("modify"))
{ // Set defaults { // Set defaults
splashdef->SmallSplashSound = if (!isnew)
splashdef->NormalSplashSound = 0; { // New ones already have their defaults set before they're pushed.
splashdef->SmallSplash = SetSplashDefaults (splashdef);
splashdef->SplashBase = }
splashdef->SplashChunk = NULL; }
splashdef->ChunkXVelShift = else
splashdef->ChunkYVelShift = {
splashdef->ChunkZVelShift = 8; SC_MustGetString();
splashdef->ChunkBaseZVel = FRACUNIT;
splashdef->SmallSplashClip = 12*FRACUNIT;
splashdef->NoAlert = false;
} }
if (!SC_Compare ("{")) if (!SC_Compare ("{"))
{ {

View file

@ -1197,7 +1197,7 @@ void RP_AddLine (seg_t *line)
} }
else else
{ // The seg is only part of the wall. { // The seg is only part of the wall.
if (line->linedef->sidenum[0] != line->sidedef - sides) if (line->linedef->sidenum[0] != DWORD(line->sidedef - sides))
{ {
swap (v1, v2); swap (v1, v2);
} }

View file

@ -440,8 +440,9 @@ void SC_MustGetToken (int token)
SC_MustGetAnyToken (); SC_MustGetAnyToken ();
if (sc_TokenType != token) if (sc_TokenType != token)
{ {
SC_ScriptError ("Expected %s but got %s instead.", FString tok1 = SC_TokenName(token);
SC_TokenName(token), SC_TokenName(sc_TokenType, sc_String)); FString tok2 = SC_TokenName(sc_TokenType, sc_String);
SC_ScriptError ("Expected %s but got %s instead.", tok1.GetChars(), tok2.GetChars());
} }
} }

View file

@ -1649,7 +1649,7 @@ do_stop:
stype = PClass::FindClass (scopename); stype = PClass::FindClass (scopename);
if (stype == NULL) if (stype == NULL)
{ {
SC_ScriptError ("%s is an unknown class.", scopename); SC_ScriptError ("%s is an unknown class.", scopename.GetChars());
} }
if (!stype->IsDescendantOf (RUNTIME_CLASS(AActor))) if (!stype->IsDescendantOf (RUNTIME_CLASS(AActor)))
{ {
@ -4327,7 +4327,8 @@ void ParseClass()
} }
else else
{ {
SC_ScriptError ("Expected 'action' or 'const' but got %s", SC_TokenName(sc_TokenType, sc_String)); FString tokname = SC_TokenName(sc_TokenType, sc_String);
SC_ScriptError ("Expected 'action' or 'const' but got %s", tokname.GetChars());
} }
SC_MustGetAnyToken(); SC_MustGetAnyToken();
} }

View file

@ -404,7 +404,7 @@ static void DoJump(AActor * self, FState * CallingState, int offset)
if (classname != NAME_None) Printf("%s::", ((FName)(ENamedName)classname).GetChars()); if (classname != NAME_None) Printf("%s::", ((FName)(ENamedName)classname).GetChars());
for (int i=0;i<JumpParameters[offset+1];i++) for (int i=0;i<JumpParameters[offset+1];i++)
{ {
Printf("%s%s", dot, ((FName)(ENamedName)JumpParameters[offset+2+i])); Printf("%s%s", dot, ((FName)(ENamedName)JumpParameters[offset+2+i]).GetChars());
} }
Printf("not found in %s\n", self->GetClass()->TypeName.GetChars()); Printf("not found in %s\n", self->GetClass()->TypeName.GetChars());
return; return;

View file

@ -885,7 +885,8 @@ static ExpData *ParseExpressionA (const PClass *cls)
} }
else else
{ {
SC_ScriptError ("Unexpected token %s", SC_TokenName(sc_TokenType, sc_String)); FString tokname = SC_TokenName(sc_TokenType, sc_String);
SC_ScriptError ("Unexpected token %s", tokname.GetChars());
return NULL; return NULL;
} }
} }
@ -946,6 +947,8 @@ static ExpVal EvalExpression (ExpData *data, AActor *self, const PClass *cls)
{ {
ExpVal val; ExpVal val;
val.Type = VAL_Int; // Placate GCC
switch (data->Type) switch (data->Type)
{ {
case EX_NOP: case EX_NOP:

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="Windows-1252"?> <?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject <VisualStudioProject
ProjectType="Visual C++" ProjectType="Visual C++"
Version="8,00" Version="8.00"
Name="updaterevision" Name="updaterevision"
ProjectGUID="{6077B7D6-349F-4077-B552-3BC302EF5859}" ProjectGUID="{6077B7D6-349F-4077-B552-3BC302EF5859}"
RootNamespace="updaterevision" RootNamespace="updaterevision"
@ -95,6 +95,82 @@
Name="VCPostBuildEventTool" Name="VCPostBuildEventTool"
/> />
</Configuration> </Configuration>
<Configuration
Name="Debug|x64"
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration <Configuration
Name="Release|Win32" Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)" OutputDirectory="$(SolutionDir)$(ConfigurationName)"
@ -172,82 +248,6 @@
Name="VCPostBuildEventTool" Name="VCPostBuildEventTool"
/> />
</Configuration> </Configuration>
<Configuration
Name="Debug|x64"
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration <Configuration
Name="Release|x64" Name="Release|x64"
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)" OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"