To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

The primary repository for this project is hosted at https://github.com/sonic-visualiser/sv-dependency-builds .
This repository is a read-only copy which is updated automatically every hour.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / src / fftw-3.3.8 / CONVENTIONS @ 167:bd3cc4d1df30

History | View | Annotate | Download (2.23 KB)

1
Code conventions used internally by fftw3 (not in API):
2

    
3
LEARN FROM THE MASTERS: read Ken Thompson's C compiler in Plan 9.
4
   Avoid learning from C++/Java programs.
5

    
6
INDENTATION: K&R, 5 spaces/tab.  In case of doubt, indent -kr -i5.
7

    
8
NAMES: keep them short.  Shorter than you think.  The Bible was written
9
   without vowels.  Don't outsmart the Bible.
10

    
11
   Common names:
12

    
13
   R       : real type, aka fftw_real
14
   E       : real type for local variables (possibly extra precision)
15
   C       : complex type
16
   sz      : size
17
   vecsz   : vector size
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)
22
   A       : assert
23
   CK      : check
24
   S       : solver, defined internally to each solver file
25
   P       : plan, defined internally to each solver file
26
   k       : codelet
27
   X(...)  : used for mangling of external names (see below)
28
   K(...)  : floating-point constant, in E precision
29

    
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.
32

    
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.
37

    
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
42
    mangled.
43

    
44
REPEATED CODE: favor a table.  E.g., do not write
45

    
46
    foo("xxx", 1);
47
    foo("yyy", 2);
48
    foo("zzz", -1);
49

    
50
    Instead write
51

    
52
      struct { const char *nam, int arg } footab[] = {
53
	{ "xxx", 1 },
54
	{ "yyy", 2 },
55
	{ "zzz", -1 }
56
      };
57

    
58
    and loop over footab.  Rationale: it saves code space.
59
    Similarly, replace a switch statement with a table whenever
60
    possible.
61

    
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
65
    we release the code.