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