- Main Page
- Classes
- Files
- Related Pages

# RFC 8: Developer Guidelines

Author: Frank Warmerdam
Contact: warmerdam@pobox.com
Status: draft

## Purpose

This document is intended to document developer practices for the GDAL/OGR project. It will be an evolving document.

## Portability

GDAL strives to be widely portable to 32bit and 64bit computing environments. It accomplishes this in a number of ways - avoid compiler specific directives, avoiding new, but perhaps not widely available aspects of C++, and most importantly by abstracting platform specific operations in CPL functions in the gdal/port directory.

Generally speaking, where available CPL functions should be used in preference to operating system functions for operations like memory allocation, path parsing, filesystem io, multithreading functions, and ODBC access.

## Variable Naming

Much of the existing GDAL and OGR code uses an adapted Hungarian naming convention. Use of this convention is not manditory, but when maintaining code using this convention it is desirable to continue adhering to it with changes. Most importantly, please avoiding using it improperly as that can be very confusing.

In Hungarian prefixing the prefix tells something about about the type, and potentially semantics of a variable. The following are some prefixes used in GDAL/OGR.

- p: pointer
- a: array
- sz: zero terminated string (eg." char szName[100];")
- psz: pointer to a zero terminated string. (eg. "char *pszName;")
- n: integer number (size unspecified)
- i: integer number used as a zero based array or loop index.
- f: floating point value (single precision)
- df: floating point value (double precision)
- o: c++ object
- os: CPLString
- h: an opaque handle (such as GDALDatasetH).

Prefix can be stacked. The following are some examples of meaningful variables.

- char **papszTokens: Pointer to an array of strings.
- int *panBands: Pointer to an array of numbers.
- double *padfScanline: Pointer to an array of doubles.
- double *pdfMeanRet: Pointer to a single double.
- GDALRasterBand *poBand: Pointer to a single object.

It may also be noted that the standard convention for variable names is to capitalize each word in a variable name.

## Headers, and Comment Blocks

## Misc. Notes

- Use lower case filenames.
- Use .cpp extension for C++ files (not .cc).
- Avoid spaces or other special characters in file or directory names.
- Use 4 character indentation levels.
- Use spaces instead of hard tab characters in source code.
- Try to keep lines to 79 characters or less.

Generated for GDAL by 1.5.1.