[m-dev.] for review: update c_coding_guidelines.html
Fergus Henderson
fjh at cs.mu.OZ.AU
Sun Feb 13 01:43:03 AEDT 2000
On 09-Feb-2000, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
>
> > > Yes, I know. However, that does not justify misleading examples.
> >
> > But our coding guidelines only require `MR_' or `ML_' prefixes for
> > symbols that are exported. If the `DirectoryEntry' type above is
> > defined in a `.c' file rather than a header file, then no prefix
> > is needed. So the example is quite valid.
>
> It is valid, but also misleading; there is nothing in the example
> that says "this type is okay because the type is local". Using an
> MR_ prefix would make the example apply to global as well as local types,
> since an MR_ prefix on local types does not hurt, but its absence
> on global types does.
Well, I suppose adding prefixes to those examples won't do any harm.
I added prefixes (alternating between MR_ and ML_) to all the examples
in the "Naming conventions" section (see the relative diff below).
I also applied both of Warwick's suggestions. I'll commit this now.
--- c_coding_standard.html.old Wed Feb 9 15:14:25 2000
+++ c_coding_standard.html Sun Feb 13 01:36:22 2000
@@ -296,23 +308,23 @@
4. Naming conventions</h2>
<h3>
-4.1. Function and variable names</h3>
+4.1. Functions, function-like macros, and variables</h3>
Use all lowercase with underscores to separate words.
-For instance, <tt>soul_machine</tt>.
+For instance, <tt>MR_soul_machine</tt>.
<h3>
-4.2. Enumeration constants, macros and #define constants</h3>
+4.2. Enumeration constants, #define constants, and non-function-like macros</h3>
Use all uppercase with underscores to separate words.
-For instance, <tt>MAX_HEADROOM</tt>.
+For instance, <tt>ML_MAX_HEADROOM</tt>.
<h3>
4.3. Typedefs</h3>
Use first letter uppercase for each word, other letters lowercase and
underscores to separate words.
-For instance, <tt>Directory_Entry</tt>.
+For instance, <tt>MR_Directory_Entry</tt>.
<h3>
4.4. Structs and unions</h3>
@@ -322,9 +334,9 @@
to the typedef name:
<font color="#0000ff">
<pre>
- typedef struct Directory_Entry_Struct {
+ typedef struct MR_Directory_Entry_Struct {
...
- } DirectoryEntry;
+ } MR_DirectoryEntry;
</pre>
<font color="#000000">
@@ -332,6 +344,10 @@
<h3>
4.5. Mercury specifics </h3>
+
+Every symbol that is externally visible (i.e. declared in a header
+file) should be prefixed with a prefix that is specific to the
+package that it comes from.
For anything exported from mercury/runtime, prefix it with MR_.
For anything exported from mercury/library, prefix it with ML_.
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3 | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list