1 | C++ conventions |
---|
2 | --------------- |
---|
3 | - struct are used in sense of C, otherwise use a class |
---|
4 | - a class must have a constructor and destruction, do not rely on the default ones |
---|
5 | - avoid virtual methods, if possible |
---|
6 | - under all circumstances, avoid multiple inheritance |
---|
7 | - remember, that Singular has C and C++ parts, i.e. ia C compiler must be able |
---|
8 | to comple your .h file (wrap C++-only parts in #ifdef) |
---|
9 | - use // comments only in C++-parts |
---|
10 | |
---|
11 | |
---|
12 | Compiler conventions |
---|
13 | -------------------- |
---|
14 | - should compile with gcc/g++ version 2.9.3 to 4.x |
---|
15 | - should create correct code with gcc/g++ version 2.9.3 to 4.x : with |
---|
16 | well known exeptions |
---|
17 | ( IA64: gcc 4.0.x, 4.1.x produce wrong code, |
---|
18 | OsX: ..., etc.) |
---|
19 | |
---|
20 | Naming conventions(variables/functions/methods): |
---|
21 | ------------------------------------------------ |
---|
22 | - global names start with a prefix in small letters, |
---|
23 | describing the general field of that routine |
---|
24 | and have capital initial letters. |
---|
25 | Example: pGetExp |
---|
26 | - local names should be short and, |
---|
27 | if they coantain a capital letter, start with a capital letter. |
---|
28 | Example: i |
---|
29 | - macros (which do not substitute procedures) should be all in capital letters. |
---|
30 | Example: INT_MAX |
---|
31 | |
---|
32 | Naming conventions(filenames, libraries): |
---|
33 | ----------------------------------------- |
---|
34 | - to avoid confusion on poor file systems, |
---|
35 | filenames should be all in small letters, or, at least, be unique if converted |
---|
36 | to small letters |
---|
37 | |
---|
38 | Error messages: |
---|
39 | -------------- |
---|
40 | - allways test for wrong input from the user, |
---|
41 | report errors via Werror/WerrorS, warnings via Warn/WarnS |
---|
42 | - trust other parts of Singular: |
---|
43 | - only very fast tests |
---|
44 | - have a complete test of the input in debug mode (#ifndef NDEBUG) |
---|
45 | - report internal errors via dReportError |
---|
46 | |
---|
47 | Indentiation: |
---|
48 | ------------- |
---|
49 | - matching { } should be in the same line (for very short staements) |
---|
50 | or in the same column |
---|
51 | |
---|
52 | System dependicies: |
---|
53 | ------------------ |
---|
54 | - for code specific for certain cpu types, use the following macros |
---|
55 | CPU type: i[3456]86: SI_CPU_I386 |
---|
56 | CPU type: sparc: SI_CPU_SPARC |
---|
57 | CPU type: ppc: SI_CPU_PPC |
---|
58 | CPU type: IA64: SI_CPU_IA64 |
---|
59 | CPU type: x86_64: SI_CPU_X86_64 |
---|
60 | - always provide a general version also |
---|
61 | - if NTL is included, one may also use: |
---|
62 | NTL_AVOID_BRANCHING (currently not used, substituted by SI_CPU_*) |
---|
63 | - only for dependencies on the OS, use |
---|
64 | the result of singuname (#ifdef ix86_Linux etc.) |
---|
65 | |
---|
66 | Misc. remarks: |
---|
67 | -------------- |
---|
68 | * never use fopen, but myfopen, in order to open text files |
---|
69 | |
---|
70 | * call rComplete after constructing a ring |
---|
71 | |
---|
72 | * note: you will get a purely commutative ring from rCopy/rCopy0/rComplete, |
---|
73 | * if you want to construct a noncommutative ring you need to call |
---|
74 | * the general nc_CallPlural or nc_rComplete whenever appropriate |
---|
75 | |
---|
76 | |
---|
77 | * never allocate memory with 0 as size request |
---|
78 | |
---|