1
Code conventions used internally by fftw3 (not in API):
3
LEARN FROM THE MASTERS: read Ken Thompson's C compiler in Plan 9.
4
Avoid learning from C++/Java programs.
6
INDENTATION: K&R, 5 spaces/tab. In case of doubt, indent -kr -i5.
8
NAMES: keep them short. Shorter than you think. The Bible was written
9
without vowels. Don't outsmart the Bible.
13
R : real type, aka fftw_real
14
E : real type for local variables (possibly extra precision)
18
is, os : input/output stride
19
ri, ii : real/imag input (complex data)
20
ro, io : real/imag output (complex data)
21
I, O : real input/output (real data)
24
S : solver, defined internally to each solver file
25
P : plan, defined internally to each solver file
27
X(...) : used for mangling of external names (see below)
28
K(...) : floating-point constant, in E precision
30
If a name is used often and must have the form fftw_foo to avoid
31
namespace pollution, #define FOO fftw_foo and use the short name.
33
Leave that hungarian crap to MS. foo_t counts as hungarian: use
34
foo instead. foo is lowercase so that it does not look like a DOS
35
program. Exception: typedef struct foo_s {...} foo; instead of
36
typedef struct foo {...} foo; for C++ compatibility.
38
NAME MANGLING: use X(foo) for external names instead of fftw_foo.
39
X(foo) expands to fftwf_foo or fftw_foo, depending on the
40
precision. (Unfortunately, this is a ugly form of hungarian
41
notation. Grrr...) Names that are not exported do not need to be
44
REPEATED CODE: favor a table. E.g., do not write
52
struct { const char *nam, int arg } footab[] = {
58
and loop over footab. Rationale: it saves code space.
59
Similarly, replace a switch statement with a table whenever
62
C++: The code should compile as a C++ program. Run the code through
63
gcc -xc++ . The extra C++ restrictions are unnecessary, of
64
course, but this will save us from a flood of complaints when