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