ISO C 90 (or C-99 without GNU-extensions) compatibility fix:

* change all casts using the typeof() keyword to their respective typename
 * append a compiler flag for GCC (-fno-gnu-keywords) which disables GNU-specific keywords (typeof and asm only in case of C-99, inline as well if C-90 mode is used), to aid in code portability (i.e. among compilers)

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@970 4a71c877-e1ca-e34f-864e-861f7616d084
master
Giel van Schijndel 2007-01-08 12:42:51 +00:00
parent 68d435097e
commit 9c79b6b109
14 changed files with 39 additions and 38 deletions

View File

@ -65,6 +65,7 @@ CC=g++
CFLAGS+=-fpermissive
else
CC=gcc
CFLAGS+=-fno-gnu-keywords
endif
ifeq ($(strip $(MODE)),debug)

View File

@ -84,7 +84,7 @@ void snapInitVars(void)
void AllocateSnapBuffer(CURSORSNAP *SnapBuffer,UWORD MaxSnaps)
{
SnapBuffer->SnapCoords = (typeof(SnapBuffer->SnapCoords))MALLOC(sizeof(CURSORSNAP)*MaxSnaps);
SnapBuffer->SnapCoords = (SNAPCOORD*)MALLOC(sizeof(CURSORSNAP)*MaxSnaps);
SnapBuffer->MaxSnaps = MaxSnaps;
SnapBuffer->NumSnaps = 0;
SnapBuffer->CurrentSnap = 0;

View File

@ -4240,7 +4240,7 @@ BOOL writeGameFile(char *pFileName, SDWORD saveType)
/* Allocate the data buffer */
fileSize = GAME_HEADER_SIZE + sizeof(SAVE_GAME);
pFileData = (typeof(pFileData))MALLOC(fileSize);
pFileData = (char*)MALLOC(fileSize);
if (pFileData == NULL)
{
debug( LOG_ERROR, "Out of memory" );
@ -6470,7 +6470,7 @@ BOOL writeDroidFile(char *pFileName, DROID **ppsCurrentDroidLists)
/* Allocate the data buffer */
fileSize = DROID_HEADER_SIZE + totalDroids*sizeof(SAVE_DROID);
pFileData = (typeof(pFileData))MALLOC(fileSize);
pFileData = (char*)MALLOC(fileSize);
if (pFileData == NULL)
{
debug( LOG_ERROR, "Out of memory" );
@ -7780,7 +7780,7 @@ BOOL writeStructFile(char *pFileName)
/* Allocate the data buffer */
fileSize = STRUCT_HEADER_SIZE + totalStructs*sizeof(SAVE_STRUCTURE);
pFileData = (typeof(pFileData))MALLOC(fileSize);
pFileData = (char*)MALLOC(fileSize);
if (pFileData == NULL)
{
debug( LOG_ERROR, "Out of memory" );
@ -8546,7 +8546,7 @@ BOOL writeFeatureFile(char *pFileName)
/* Allocate the data buffer */
fileSize = FEATURE_HEADER_SIZE + totalFeatures * sizeof(SAVE_FEATURE);
pFileData = (typeof(pFileData))MALLOC(fileSize);
pFileData = (char*)MALLOC(fileSize);
if (pFileData == NULL)
{
debug( LOG_ERROR, "Out of memory" );
@ -9179,7 +9179,7 @@ BOOL writeTemplateFile(char *pFileName)
/* Allocate the data buffer */
fileSize = TEMPLATE_HEADER_SIZE + totalTemplates*sizeof(SAVE_TEMPLATE);
pFileData = (typeof(pFileData))MALLOC(fileSize);
pFileData = (char*)MALLOC(fileSize);
if (pFileData == NULL)
{
debug( LOG_ERROR, "Out of memory" );
@ -9353,7 +9353,7 @@ static BOOL writeTerrainTypeMapFile(char *pFileName)
// Calculate the file size
fileSize = TILETYPE_HEADER_SIZE + sizeof(UWORD) * MAX_TILE_TEXTURES;
pFileData = (typeof(pFileData))MALLOC(fileSize);
pFileData = (char*)MALLOC(fileSize);
if (!pFileData)
{
debug( LOG_ERROR, "writeTerrainTypeMapFile: Out of memory" );
@ -9582,7 +9582,7 @@ static BOOL writeCompListFile(char *pFileName)
numProgramStats) * MAX_PLAYERS;
fileSize = COMPLIST_HEADER_SIZE + (sizeof(SAVE_COMPLIST) * totalComp);
//allocate the buffer space
pFileData = (typeof(pFileData))MALLOC(fileSize);
pFileData = (char*)MALLOC(fileSize);
if (!pFileData)
{
debug( LOG_ERROR, "writeCompListFile: Out of memory" );
@ -9907,7 +9907,7 @@ static BOOL writeStructTypeListFile(char *pFileName)
numStructureStats * MAX_PLAYERS);
//allocate the buffer space
pFileData = (typeof(pFileData))MALLOC(fileSize);
pFileData = (char*)MALLOC(fileSize);
if (!pFileData)
{
debug( LOG_ERROR, "writeStructTypeListFile: Out of memory" );
@ -10184,7 +10184,7 @@ static BOOL writeResearchFile(char *pFileName)
numResearch);
//allocate the buffer space
pFileData = (typeof(pFileData))MALLOC(fileSize);
pFileData = (char*)MALLOC(fileSize);
if (!pFileData)
{
debug( LOG_ERROR, "writeResearchFile: Out of memory" );
@ -10409,7 +10409,7 @@ static BOOL writeMessageFile(char *pFileName)
//allocate the buffer space
pFileData = (typeof(pFileData))MALLOC(fileSize);
pFileData = (char*)MALLOC(fileSize);
if (!pFileData)
{
debug( LOG_ERROR, "writeMessageFile: Out of memory" );
@ -10607,7 +10607,7 @@ static BOOL writeProximityFile(char *pFileName)
//allocate the buffer space
pFileData = (typeof(pFileData))MALLOC(fileSize);
pFileData = (char*)MALLOC(fileSize);
if (!pFileData)
{
debug( LOG_ERROR, "writeProximityFile: Out of memory" );
@ -10906,7 +10906,7 @@ static BOOL writeFlagFile(char *pFileName)
//allocate the buffer space
pFileData = (typeof(pFileData))MALLOC(fileSize);
pFileData = (char*)MALLOC(fileSize);
if (!pFileData)
{
debug( LOG_ERROR, "writeflagFile: Out of memory" );
@ -11132,7 +11132,7 @@ static BOOL writeProductionFile(char *pFileName)
//allocate the buffer space
pFileData = (typeof(pFileData))MALLOC(fileSize);
pFileData = (char*)MALLOC(fileSize);
if (!pFileData)
{
debug( LOG_ERROR, "writeProductionFile: Out of memory" );
@ -11247,7 +11247,7 @@ BOOL loadSaveStructLimitsV19(char *pFileData, UDWORD filesize, UDWORD numLimits)
STRUCTURE_STATS *psStats;
int SkippedRecords=0;
psSaveLimits = (typeof(psSaveLimits)) MALLOC (sizeof(SAVE_STRUCTLIMITS_V2));
psSaveLimits = (SAVE_STRUCTLIMITS_V2 *) MALLOC (sizeof(SAVE_STRUCTLIMITS_V2));
if (!psSaveLimits)
{
debug( LOG_ERROR, "Out of memory" );
@ -11318,7 +11318,7 @@ BOOL loadSaveStructLimitsV(char *pFileData, UDWORD filesize, UDWORD numLimits)
STRUCTURE_STATS *psStats;
int SkippedRecords=0;
psSaveLimits = (typeof(psSaveLimits)) MALLOC (sizeof(SAVE_STRUCTLIMITS));
psSaveLimits = (SAVE_STRUCTLIMITS*) MALLOC (sizeof(SAVE_STRUCTLIMITS));
if (!psSaveLimits)
{
debug( LOG_ERROR, "Out of memory" );
@ -11396,7 +11396,7 @@ BOOL writeStructLimitsFile(char *pFileName)
// Allocate the data buffer
fileSize = STRUCTLIMITS_HEADER_SIZE + (totalLimits * (sizeof(SAVE_STRUCTLIMITS)));
pFileData = (typeof(pFileData))MALLOC(fileSize);
pFileData = (char*)MALLOC(fileSize);
if (pFileData == NULL)
{
debug( LOG_ERROR, "Out of memory" );
@ -11539,7 +11539,7 @@ BOOL writeCommandLists(char *pFileName)
// Allocate the data buffer
fileSize = COMMAND_HEADER_SIZE + (totalDroids * (sizeof(SAVE_COMMAND)));
pFileData = (typeof(pFileData))MALLOC(fileSize);
pFileData = (char*)MALLOC(fileSize);
if (pFileData == NULL)
{
debug( LOG_ERROR, "Out of memory" );

View File

@ -183,7 +183,7 @@ BOOL levParse(char *pBuffer, SDWORD size, searchPathMode datadir)
if (state == LP_START || state == LP_WAITDATA)
{
// start a new level data set
psDataSet = (typeof(psDataSet))MALLOC(sizeof(LEVEL_DATASET));
psDataSet = (LEVEL_DATASET*)MALLOC(sizeof(LEVEL_DATASET));
if (!psDataSet)
{
levError("Out of memory");
@ -356,7 +356,7 @@ BOOL levParse(char *pBuffer, SDWORD size, searchPathMode datadir)
psFoundData->psChange = psDataSet;
}
// store the level name
psDataSet->pName = (typeof(psDataSet->pName))MALLOC(strlen(pLevToken) + 1);
psDataSet->pName = (char*)MALLOC(strlen(pLevToken) + 1);
if (!psDataSet->pName)
{
levError("Out of memory");
@ -397,7 +397,7 @@ BOOL levParse(char *pBuffer, SDWORD size, searchPathMode datadir)
}
// store the data name
psDataSet->apDataFiles[currData] = (typeof(psDataSet->apDataFiles[currData]))MALLOC(strlen(pLevToken) + 1);
psDataSet->apDataFiles[currData] = (char*)MALLOC(strlen(pLevToken) + 1);
if (!psDataSet->apDataFiles[currData])
{
levError("Out of memory");

View File

@ -790,7 +790,7 @@ BOOL mapSave(char **ppFileData, UDWORD *pFileSize)
*pFileSize += 1+aNumEquiv[i];
}
*ppFileData = (typeof(*ppFileData))MALLOC(*pFileSize);
*ppFileData = (char*)MALLOC(*pFileSize);
if (*ppFileData == NULL)
{
debug( LOG_ERROR, "Out of memory" );
@ -1613,7 +1613,7 @@ BOOL writeVisibilityData( char *pFileName )
fileSize = ( sizeof(struct _vis_save_header) + ( mapEntries*sizeof(UBYTE) ) );
/* Try and allocate it - freed up in same function */
pFileData = (typeof(pFileData))MALLOC(fileSize);
pFileData = (char*)MALLOC(fileSize);
/* Did we get it? */
if(!pFileData)

View File

@ -248,7 +248,7 @@ void loadMapPreview(void)
scale = 5;
}
oursize=sizeof(unsigned char) *mywidth*myheight;
imageData = (typeof(imageData))malloc(oursize *3);
imageData = (unsigned char*)malloc(oursize *3);
ptr=imageData;
memset(ptr,0x45,sizeof(unsigned char) *mywidth*myheight*3 ); //dunno about background color
psTile = psMapTiles;

View File

@ -333,7 +333,7 @@ void createLimitSet(void)
}
//close your eyes now
pChanges = (typeof(pChanges))MALLOC(numchanges*(sizeof(UDWORD)+sizeof(UBYTE))); // allocate some mem for this.
pChanges = (UBYTE*)MALLOC(numchanges*(sizeof(UDWORD)+sizeof(UBYTE))); // allocate some mem for this.
pEntry = pChanges;
for(i=0;i<numStructureStats;i++) // prepare chunk.

View File

@ -206,7 +206,7 @@ void recvOptions(NETMSG *pMsg)
pos += sizeof(ingame.numStructureLimits);
if(ingame.numStructureLimits)
{
ingame.pStructureLimits = (typeof(ingame.pStructureLimits))MALLOC(ingame.numStructureLimits*(sizeof(UDWORD)+sizeof(UBYTE))); // malloc some room
ingame.pStructureLimits = (UBYTE*)MALLOC(ingame.numStructureLimits*(sizeof(UDWORD)+sizeof(UBYTE))); // malloc some room
memcpy(ingame.pStructureLimits, &(pMsg->body[pos]) ,ingame.numStructureLimits*(sizeof(UDWORD)+sizeof(UBYTE)));
}

View File

@ -98,7 +98,7 @@ BOOL addToForce(DROID_TEMPLATE *templ)
}
// add droid.
pF = (typeof(pF))MALLOC(sizeof(FORCE_MEMBER)); // create a slot in the force.
pF = (FORCE_MEMBER*)MALLOC(sizeof(FORCE_MEMBER)); // create a slot in the force.
if (!pF)
{
return FALSE;

View File

@ -132,7 +132,7 @@ BOOL InitRadar(void)
{
UBYTE color;
radarBuffer = (typeof(radarBuffer))MALLOC(RADWIDTH*RADHEIGHT);
radarBuffer = (UBYTE*)MALLOC(RADWIDTH*RADHEIGHT);
if(radarBuffer==NULL) return FALSE;
memset(radarBuffer,0,RADWIDTH*RADHEIGHT);

View File

@ -472,7 +472,7 @@ SCORE_SAVEHEADER *psHeader; // Pointer to the header part of the file
fileSize = ( sizeof(struct _score_save_header) + sizeof(struct mission_data) );
/* Try and allocate it - freed up in same function */
pFileData = (typeof(pFileData))MALLOC(fileSize);
pFileData = (char*)MALLOC(fileSize);
/* Did we get it? */
if(!pFileData)

View File

@ -82,14 +82,14 @@ BOOL scrvAddContext(char *pID, SCRIPT_CONTEXT *psContext, SCRV_TYPE type)
{
SCRV_STORE *psNew;
psNew = (typeof(psNew))MALLOC(sizeof(SCRV_STORE));
psNew = (SCRV_STORE*)MALLOC(sizeof(SCRV_STORE));
if (!psNew)
{
debug( LOG_ERROR, "scrvAddContext: Out of memory" );
abort();
return FALSE;
}
psNew->pIDString = (typeof(psNew->pIDString))MALLOC(strlen(pID) + 1);
psNew->pIDString = (char*)MALLOC(strlen(pID) + 1);
if (!psNew->pIDString)
{
debug( LOG_ERROR, "scrvAddContext: Out of memory" );

View File

@ -311,13 +311,13 @@ BOOL seq_SetupVideoBuffers(void)
UBYTE r,g,b;
//assume 320 * 240 * 16bit playback surface
mallocSize = (RPL_WIDTH*RPL_HEIGHT*RPL_DEPTH);
if ((pVideoBuffer = (typeof(pVideoBuffer))MALLOC(mallocSize)) == NULL)
if ((pVideoBuffer = (char*)MALLOC(mallocSize)) == NULL)
{
return FALSE;
}
mallocSize = 1<<(RPL_BITS_555);//palette only used in 555mode
if ((pVideoPalette = (typeof(pVideoPalette))MALLOC(mallocSize)) == NULL)
if ((pVideoPalette = (char*)MALLOC(mallocSize)) == NULL)
{
return FALSE;
}

View File

@ -75,8 +75,8 @@ void makeTileTexturePages(UDWORD srcWidth, UDWORD srcHeight, UDWORD tileWidth, U
/* Get enough memory to store one tile */
pageNumber = 0;
tileStorage = (typeof(tileStorage))MALLOC(tileWidth * tileHeight * PAGE_DEPTH);
sprite.bmp = (typeof(sprite.bmp))MALLOC(TEXTURE_PAGE_SIZE);
tileStorage = (unsigned char*)MALLOC(tileWidth * tileHeight * PAGE_DEPTH);
sprite.bmp = (iBitmap*)MALLOC(TEXTURE_PAGE_SIZE);
sprite.width = PAGE_WIDTH;
sprite.height = PAGE_HEIGHT;
tilesProcessed = 0;
@ -112,7 +112,7 @@ void makeTileTexturePages(UDWORD srcWidth, UDWORD srcHeight, UDWORD tileWidth, U
tilesDown, tilesAcross, tilesProcessed, tilesPerPage);
/* If so, download this one and reset to start again */
pageId[pageNumber] = pie_AddBMPtoTexPages(&sprite, "terrain", 0, TRUE, FALSE);
sprite.bmp = (typeof(sprite.bmp))MALLOC(TEXTURE_PAGE_SIZE);
sprite.bmp = (iBitmap*)MALLOC(TEXTURE_PAGE_SIZE);
pageNumber++;
presentLoc = sprite.bmp;
}
@ -151,12 +151,12 @@ void remakeTileTexturePages(UDWORD srcWidth,UDWORD srcHeight, UDWORD tileWidth,
/* Get enough memory to store one tile */
pageNumber = 0;
tileStorage = (typeof(tileStorage))MALLOC(tileWidth * tileHeight * PAGE_DEPTH);
tileStorage = (unsigned char*)MALLOC(tileWidth * tileHeight * PAGE_DEPTH);
// texturePage = (typeof(texturePage))MALLOC(TEXTURE_PAGE_SIZE);
sprite.width = PAGE_WIDTH;
sprite.height = PAGE_HEIGHT;
sprite.bmp = (typeof(sprite.bmp))MALLOC(TEXTURE_PAGE_SIZE);
sprite.bmp = (iBitmap*)MALLOC(TEXTURE_PAGE_SIZE);
// memset(sprite.bmp,0,TEXTURE_PAGE_SIZE);
tilesProcessed = 0;
tilesAcross = srcWidth/tileWidth;