[gdal-dev] Re: CPL questions

Frank Warmerdam warmerda at h...
Fri Jan 15 09:50:33 EST 1999


charset="us-ascii"
content-transfer-encoding: 7bit
content-type: text/plain; charset=us-ascii

Daniel Morissette wrote:
> 
> Hi Frank,
> 
> I was looking at the stuff in the portability library to see which part
> I could use as a base for my binary coverage library and I have a couple
> of questions for you:
> 
> - First I noticed that all the files are .cpp in the port directory,
> even if they contain only C code... is there any reason for that? Since
> the header files contain a CPL_C_START/END, I assume that it is safe for
> me to just change the file extensions to ".c" if I want my lib to
> contain exclusively C stuff.

Daniel,

It is my intention to compile all new GDAL code as C++ for it's ``a better
C than C'' properties (error checking and so forth), while keeping some
core services in CPL C compilable so they can be used in some ``C++ hostile''
environments. 

If you find code in gdal/port that isn't C compilable, then please patch
it up accordingly. 

> - Do you have any convenience functions for access to binary files or do
> you just use fseek/fread (or VSIFseek/VSIFread) directly in your binary
> translators?

I don't have anything, and wasn't planning to add DKRead() analog. I am
trying to ``get with stdio''. 

> - There does not seem to be anything yet with respect to byte swapping.
> For now I have my own macros, but it would probably be a good idea to
> use a standard method in all GDAL code. I saw that you used a
> SwapWord() function inside your shapelib library... is it the kind of
> function that we should migrate to the CPL? Or would macros be more
> efficient than the loop used in SwapWord()? Also, I really like the way
> you test on the fly if the current system is MSB or LSB inside
> shpopen.c... it could probably become a convenience function in the CPL?

You are correct that I haven't addressed generic byte swapping ... I 
encourage you to do so! While I liked the auto-detection of byte order
in shpopen.c because it avoiding having any configuration issues for a
builder to deal within in the include files, I don't think that it should
be used in GDAL. I believe that there will be places where we want to 
know at compile time what the native byte order is.

To that end, it is my intention that CPL_LSB or CPL_MSB be defined in
cpl_port.h depending on the system. I am not sure how we will drive
this. Eventually I would like to have GNU style ``configure'' working
which can presumably take care of this issue. In the meantime, we can
just do it adhoc in cpl_port.h. 

I have also attached some email from Liujian with his efficient word
swapping macros. I think we should use something like this, rather than
the traditional PCI function calls. Also, I think the macro names should
be CPL-ized so they won't conflict with GPC, or anything else. 

Can you take care of all that?

BTW, I have secured access to an old Sun running BSD for testing software
on an MSB system. If you have something you would like me to test let me
know. If necessary, I imagine Dave Gilbert would be willing to give some
trusted others access to the system as well. It's slow, but it's MSB!

> For now I'm not sure if the final version of my lib will link directly
> with the CPL, or if I will just copy the parts I need from it and put
> all of them in the same C file. Using the second option could be nice
> because it adds only one file to the core library, and if we
> want to reuse the code in GDAL then we remove that C file and link with
> the CPL instead.

I have included parts of CPL in a recent delivery to Global Geomatics. 
In that case I just renamed the .cpp files to .c, and dumped them in with
the driver I wrote. There is no harm in merging them into a single file as
well for simplicity. 

As per our earlier design discussions, it should be possible to grab parts
of CPL pretty easily and use them for other projects. 

Best regards,

---------------------------------------+--------------------------------------
I set the clouds in motion - turned up | Frank Warmerdam, Programmer for Rent
light and sound - activate the windows | http://members.home.com/warmerda
and watch the world go round - Rush | warmerda at h...

------------------------------------------------------------------------
eGroup home: http://www.eGroups.com/list/gdal-dev
Free Web-based e-mail groups by eGroups.com

-------------- next part --------------
An embedded message was scrubbed...
From: unknown sender
Subject: no subject
Date: no date
Size: 2507
Url: http://lists.osgeo.org/pipermail/gdal-dev/attachments/19990115/199d7a99/attachment.mht


More information about the Gdal-dev mailing list