cannam@127: Code conventions used internally by fftw3 (not in API): cannam@127: cannam@127: LEARN FROM THE MASTERS: read Ken Thompson's C compiler in Plan 9. cannam@127: Avoid learning from C++/Java programs. cannam@127: cannam@127: INDENTATION: K&R, 5 spaces/tab. In case of doubt, indent -kr -i5. cannam@127: cannam@127: NAMES: keep them short. Shorter than you think. The Bible was written cannam@127: without vowels. Don't outsmart the Bible. cannam@127: cannam@127: Common names: cannam@127: cannam@127: R : real type, aka fftw_real cannam@127: E : real type for local variables (possibly extra precision) cannam@127: C : complex type cannam@127: sz : size cannam@127: vecsz : vector size cannam@127: is, os : input/output stride cannam@127: ri, ii : real/imag input (complex data) cannam@127: ro, io : real/imag output (complex data) cannam@127: I, O : real input/output (real data) cannam@127: A : assert cannam@127: CK : check cannam@127: S : solver, defined internally to each solver file cannam@127: P : plan, defined internally to each solver file cannam@127: k : codelet cannam@127: X(...) : used for mangling of external names (see below) cannam@127: K(...) : floating-point constant, in E precision cannam@127: cannam@127: If a name is used often and must have the form fftw_foo to avoid cannam@127: namespace pollution, #define FOO fftw_foo and use the short name. cannam@127: cannam@127: Leave that hungarian crap to MS. foo_t counts as hungarian: use cannam@127: foo instead. foo is lowercase so that it does not look like a DOS cannam@127: program. Exception: typedef struct foo_s {...} foo; instead of cannam@127: typedef struct foo {...} foo; for C++ compatibility. cannam@127: cannam@127: NAME MANGLING: use X(foo) for external names instead of fftw_foo. cannam@127: X(foo) expands to fftwf_foo or fftw_foo, depending on the cannam@127: precision. (Unfortunately, this is a ugly form of hungarian cannam@127: notation. Grrr...) Names that are not exported do not need to be cannam@127: mangled. cannam@127: cannam@127: REPEATED CODE: favor a table. E.g., do not write cannam@127: cannam@127: foo("xxx", 1); cannam@127: foo("yyy", 2); cannam@127: foo("zzz", -1); cannam@127: cannam@127: Instead write cannam@127: cannam@127: struct { const char *nam, int arg } footab[] = { cannam@127: { "xxx", 1 }, cannam@127: { "yyy", 2 }, cannam@127: { "zzz", -1 } cannam@127: }; cannam@127: cannam@127: and loop over footab. Rationale: it saves code space. cannam@127: Similarly, replace a switch statement with a table whenever cannam@127: possible. cannam@127: cannam@127: C++: The code should compile as a C++ program. Run the code through cannam@127: gcc -xc++ . The extra C++ restrictions are unnecessary, of cannam@127: course, but this will save us from a flood of complaints when cannam@127: we release the code.