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