[Gdal-dev] Structure member alignment suggestion

Frank Warmerdam warmerdam at pobox.com
Tue Jan 31 07:51:09 EST 2006


On 1/31/06, Ray Gardener <rayg at daylongraphics.com> wrote:
> 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).

Ray,

The appropriate place would likely be:
  http://www.gdal.org/gdal_building.html

But I am hesitant to complicate this page with structure packing issues,
especially since I'm not sure what to say.

> 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;
>         ...
>    }

I have renamed bFinderInitialized to bCSVFinderInitialized in
cpl_csv.cpp to avoid the name conflict.

> 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.

Well, the "s" prefix is not a convention I follow and I'm hesitant to add
it now after all these years.  I do try to prefix true globals (not just
module scoped variables) with "g" but then I also try to avoid having
real globals.

Best regards,
--
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent




More information about the Gdal-dev mailing list