From b40df56f263227e697ca3fb92720301646cb18a1 Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Thu, 23 Sep 2004 16:03:48 +0000 Subject: [PATCH] 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 --- docs/CodingStandards.html | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/CodingStandards.html b/docs/CodingStandards.html index c1e1a1dd90d..8171130e2a2 100644 --- a/docs/CodingStandards.html +++ b/docs/CodingStandards.html @@ -29,6 +29,7 @@
  • Treat Compiler Warnings Like Errors
  • Write Portable Code
  • +
  • Use of class/struct Keywords
  • Style Issues @@ -366,6 +367,23 @@ to support it.

    + + +
    +

    In C++ the class and struct keywoards can be used almost + interchangeably. The only difference is when they are used to declare a class: + class makes all members private by default while struct + makes all members public by defaut.

    +

    Unfortunately, not all compilers follow the rules and some will generate + different symbols based on whether class or struct was used + to declare the symbol. This can lead to problems at link time.

    +

    So, the rule for LLVM is this: "always use the class keyword, + unless all members are public in which case struct is + allowed.

    +
    +