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