diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2004-09-23 16:03:48 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2004-09-23 16:03:48 +0000 |
commit | b40df56f263227e697ca3fb92720301646cb18a1 (patch) | |
tree | e4c5133fb48831cd86b7e77c6d256cec70f2f0cd /docs/CodingStandards.html | |
parent | 684fe210a936216d5a2d0c01d29d7ad184441b03 (diff) |
Add a blurb about the use of class vs. struct keyword in class decls.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16500 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'docs/CodingStandards.html')
-rw-r--r-- | docs/CodingStandards.html | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/docs/CodingStandards.html b/docs/CodingStandards.html index c1e1a1dd90..8171130e2a 100644 --- a/docs/CodingStandards.html +++ b/docs/CodingStandards.html @@ -29,6 +29,7 @@ <li><a href="#ci_warningerrors">Treat Compiler Warnings Like Errors</a></li> <li><a href="#ci_portable_code">Write Portable Code</a></li> + <li><a href="#ci_class_struct">Use of class/struct Keywords</a></li> </ol></li> </ol></li> <li><a href="#styleissues">Style Issues</a> @@ -366,6 +367,23 @@ to support it.</p> </div> +<!-- _______________________________________________________________________ --> +<div class="doc_subsubsection"> +<a name="ci_class_struct">Use of <tt>class</tt> and <tt>struct</tt> Keywords</a> +</div> +<div class="doc_text"> + <p>In C++ the <tt>class</tt> and <tt>struct</tt> keywoards can be used almost + interchangeably. The only difference is when they are used to declare a class: + <tt>class</tt> makes all members private by default while <tt>struct</tt> + makes all members public by defaut.<p> + <p>Unfortunately, not all compilers follow the rules and some will generate + different symbols based on whether <tt>class</tt> or <tt>struct</tt> was used + to declare the symbol. This can lead to problems at link time.</p> + <p>So, the rule for LLVM is this: "always use the <tt>class</tt> keyword, + unless <b>all</b> members are public in which case <tt>struct</tt> is + allowed.</p> +</div> + <!-- *********************************************************************** --> <div class="doc_section"> <a name="styleissues">Style Issues</a> |