[Gdal-dev] Structure member alignment suggestion

Ray Gardener rayg at daylongraphics.com
Tue Jan 31 07:15:20 EST 2006


Frank Warmerdam wrote:
> I have made the suggested change in ogr_spatialref.h
> (warning ... ABI change!) but I think that depending on this
> or pragmas to ensure compatible structure packing is
> problematic at best so this isn't something I am going to
> pursue religiously in all include files.

Yeah, it's not a crisis since one can build GDAL with whatever packing 
is needed. A note in the INSTALL docs or wherever might be handy though, 
just in case someone runs into this issue (which can be hard to 
troubleshoot sometimes).

Oh, something else, not a huge deal either but would make life easier in 
the MSVC debugger, which has trouble telling module-level and 
function-level static vars of the same name apart:

port\cpl_findfile.cpp has
   static CPL_THREADLOCAL int bFinderInitialized = FALSE;

and port\cpl_csv.cpp has
   const char * GDALDefaultCSVFilename( const char *pszBasename )
   {
       static CPL_THREADLOCAL int bFinderInitialized = FALSE;
   	...
   }

The first time through the function, the debugger thinks 
bFinderInitialized is TRUE, not realizing its showing the contents of 
the module-level var, not the function's. The program flow behaves 
correctly, however; it's just a debugger display error -- probably takes 
whatever symbol of the desired name is first in the globals section and 
goes with that.

FWIW, I'd suggest prefixing the module-level static with 's' or 'g' to 
show higher scope and uniquely id'ing it in one shot. Plus if one is 
doing a 'Find in files' with 'match whole word' one won't get both vars 
showing in the search results.

Ray



More information about the Gdal-dev mailing list