[Mapserver-dev] Coding Standards

Frank Warmerdam warmerdam at pobox.com
Thu Feb 27 10:45:41 EST 2003


Steve Lime wrote:
>>Subject says it all. Depending on who wrote the code rumaging through
>>the source can be kinda trying. I'm thinking we need a document that
>>lays out coding standards, especially as the list of developers grows.
>>For example, I like the naming convension that some folks use for
>>function parameters and local variables and would like to adopt that
>>myself. However, I (personally) hate if-then's or function calls that
>>span multiple lines- have to scroll too much when editing. Thoughts?

Steve,

I can't say that I am excited at the concept of setting out code style
guidelines for MapServer.  While for some time I tried to fit into the
existing MapServer style, I see on review that have slipped into increasing
amounts of my own variable naming conventions in some modules.

So contrary to Daniel's position, I would be happy enough to have the issue
drop!  My general position in GDAL has been, people should fit into the style
of the module (file) they are working on, and for new files they write, they
can do it in any reasonable style.

If we were to select one, it would seem expedient for it to match the
bulk of material already written by Steve rather than the PCI derived style
that Assefa, Daniel and I tend to use.   I would add that I am not interested
in spending a bunch of time reworking styles.

I would like to suggest we develop a standard file header style, and for
this I *would* propose what Daniel, Assefa and I have been using.  See
mapogr.cpp or mapresample.c as examples.

Furthermore, I would like to see CVS ids embedded in the object files.
In GDAL I do this by including the following macro in each source file,
just after the include files:

CPL_CVSID("$Id: gdalopen.cpp,v 1.18 2003/02/03 05:09:31 warmerda Exp $");

CPL_CVSID is defined as follows, but the idea is basically to create
a static variable in each module that contains the CVS $Id$ string.  Then
the "ident" (or strings) program can be used to find the exact CVS version
of all source files used in a binary or shared library.

#ifndef DISABLE_CVSID
#  define CPL_CVSID(string)     static char cpl_cvsid[] = string; \
static char *cvsid_aw() { return( cvsid_aw() ? ((char *) NULL) : cpl_cvsid ); }
#else
#  define CPL_CVSID(string)
#endif

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 mapserver-dev mailing list