Game Development Community

C++ Build Issues

by Mike Lilligreen · in Torque 2D Professional · 03/14/2014 (11:28 pm) · 9 replies

Well, it looks like Xcode auto-updated for me so I'm now using the latest version 5.1. And of course there's about a bazillion new warnings and errors that popped up from existing code that compiled fine a few days ago - I can't get T2D to build at the moment. I'm stuck at this error in AssetManager.cc, line 2225:

S32 AssetManager::findAssetLooseFile( AssetQuery* pAssetQuery, const char* pLooseFile, const bool assetQueryAsSource )
{
    // Debug Profiling.
    PROFILE_SCOPE(AssetManager_FindAssetLooseFile);

    // Sanity!
    AssertFatal( pAssetQuery != NULL, "Cannot use NULL asset query." );
    AssertFatal( pLooseFile != NULL, "Cannot use NULL loose file." );

    // Expand loose file.
    char looseFileBuffer[1024];
    Con::expandPath(looseFileBuffer, sizeof(looseFileBuffer), pLooseFile, false );  // Error is here

The last parameter "false" in expandPath is the issue "Cannot initialize a parameter of type const char* with an rvalue of type bool." I looked at the expandPath function in console.cc and it looks ok, I'm not really sure why Xcode is complaining.

Any ideas?

#1
03/14/2014 (11:33 pm)
Are you missing a parameter?

https://github.com/GarageGames/Torque2D/blob/development/engine/source/console/console.cc#L1401
#2
03/14/2014 (11:43 pm)
Educated guess :

This is actually a bug that was never found before and that most compilers don't seem to mind.

All other calls to Con::expandPath throughout the engine use the arguments correctly : findAssetLooseFile is the only case where it tries to pass a bool to a const char*.

The third argument
const char* pWorkingDirectoryHint

should be specified as NULL as in this working example from platform/platformFileIO.cc

Con::expandPath( pathBuffer, sizeof(pathBuffer), pPath, NULL, true );

To clarify, this should replace the existing code :

Con::expandPath(looseFileBuffer, sizeof(looseFileBuffer), pLooseFile, NULL, false );
#3
03/14/2014 (11:52 pm)
Ah, I didn't notice that it was missing a parameter. Thanks for the quick help guys!
#4
03/15/2014 (12:01 am)
There's a ton of errors in various ConsoleMethods where the return object is of a wrong type:

// Sanity!
    if ( shapeIndex >= shapeCount )
    {
        Con::warnf("SceneObject::getEdgeCollisionShapeLocalPositionStart() - Invalid shape index of %d.", shapeIndex);
        return false;
    }

So far to fix this I've been replacing all return false; with return StringTable->EmptyString;

Is that ok for everyone?
#5
03/15/2014 (12:13 am)
Hmmm. I don't think returning EmptyString would break anything but this should definitely be tested thoroughly to make sure it doesn't change anything on the user side.
#6
03/15/2014 (12:24 am)
Well, I'm pretty sure all the bad returns were inside of sanity checks so it shouldn't break users scripts too much as they would need to fix the console warnings they are getting anyway. T2D is building again, I'll have to get all the changes put into a pull request for review.
#7
03/15/2014 (7:45 am)
I would think the functions normally returning a pointer to something should return NULL in place of false on error. This is why disabling warnings is bad people! (looks at whoever disables massive number of warnings in Visual Studio projects).
#8
03/16/2014 (4:44 am)
Pull request is up for everyone to review.

github.com/GarageGames/Torque2D/pull/159
#9
03/17/2014 (7:48 am)
I'm glad someone verified this. I thought I was going crazy. I posted about it here but no one responded.

https://www.garagegames.com/community/forums/viewthread/136465

I figured out a workaround for it as well but it looks like it is being fixed anyway.