IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 2, 2004, 10:52:58 AM (22 years ago)
Author:
rhl
Message:

Added notes on structs and typedefs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/misc/codeConventions.tex

    r129 r131  
    11451145\code{psEquatorialToEcliptic} (\emph{not} \code{psEquatorial2Ecliptic}).
    11461146
    1147 \subsection{\label{LArgumentOrder}Order of I/O Arguments}
     1147\subsection{Order of I/O Arguments}
    11481148
    11491149Functions that assign to a variable should list that argument
    11501150\textit{first} (i.e. following the pattern of \code{strcpy}):
    11511151
    1152 \subsection{\label{LConstRestrict}Type Qualifiers (const and restrict)}
     1152\subsection{Type Qualifiers (const and restrict)}
    11531153
    11541154All interfaces and type definitions should use \code{const} and
     
    11651165\textit{N.b. compilers are free to ignore the \code{restrict} keyword,
    11661166so all code should be written to explicitly handle aliasing}.
     1167
     1168\subsection{\code{struct}s and \code{typedef}s}
     1169
     1170All structs should be defined as \code{typedef}s.
     1171
     1172A struct should not include a struct
     1173tag unless it's self-referential; E.g.
     1174\begin{verbatim}
     1175typedef struct myStruct {               // Omit "myStruct"
     1176    int x;
     1177} myStruct;
     1178
     1179typedef struct yourStruct {             // OK
     1180    struct yourStruct *next;
     1181    int x;
     1182} yourStruct;
     1183\end{verbatim}
    11671184
    11681185%------------------------------------------------------------------------------
     
    13431360  specified as \code{(void)} (avoiding complaints on some compilers,
    13441361  e.g. on SGIs).
    1345  
     1362
     1363\item
     1364  Added rules on typedefing structs, and on struct tags.
     1365
    13461366\end{itemize}
    13471367
Note: See TracChangeset for help on using the changeset viewer.