TClass, CClass, WClass ?!?

Posted on 1998-04-21
Last Modified: 2010-04-10
  I'm in the position of writing a moderately sized C++ project and I wan't to make sure that the classes that I declare won't clash with class names of the compiler.
   So Microsoft use the CClass naming covention, Borland use TClass. I want to know what naming conventions other major compilers (eg Watcom) use so that I can avoid them.
    I've been told that Borland strips the first character from all classnames on it's component pallette in Builder; can anyone confirm or deny this allegation. I assume there is a way of "overriding" this - what is it?
     Finally is there a way of grouping my header files so that I can make sure the right one is included when a file has a Borland or Microsoft namesake.

- OK so the last question was a bit of a red herring as the compiler will be sure to tell me in one way or the other if it is using Borland's tree.h file instead of my tree.h file and if I'd specified the path the problem wouldn't have arisen.
Anyway thanks to all, alexo get's the points for telling me the version numbers. Nietod would have got them if he had - he'll probably get them next time anyway.  Extended thanks to all.

PS Alexo you'll need to reply to get those points I think
Question by:gavinpat
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
LVL 22

Expert Comment

ID: 1162824
namespaces are the best way to prevent naming clashes.  The idea of prefixing names with a letter was developed before namespaces were introduced and is an imperfect solution.  (If it were a perfect solution, you wouldn't be asking this question...)  

Expert Comment

ID: 1162825
I am afraid namespaces are not yet widely supported. In the mean while, you can use longer prefixes (2-3 letters), so the probablility of a name clash will be smaller.

As for your second question, do you mean something like the following?

#ifdef _MSC_VER
#include "ms_header.h"
#elif defined(__BORLANDC__)
#include "borland_header.h"
#elif defined (__WATCOM_CPLUSPLUS__)
#include "watcom_header.h"
#error "unknown compiler"
LVL 11

Expert Comment

ID: 1162826
Namespaces are supported by MSVC (verified in version 4.2) and Borland (verified in BC++ version 5.02)
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 1162827
Edited text of question

Author Comment

ID: 1162828
Edited text of question
LVL 22

Expert Comment

ID: 1162829
gavinpat.  In the future you should post comments to your question rather than re-edtign the question.  It is a little easier to read and keeps a more chronological log of the discussion.  I mention this because Alexo may have missed your request for him to answer the question.  Try posting the request in a comment.

Author Comment

ID: 1162830
Come and get those points Alexo!

LVL 11

Accepted Solution

alexo earned 50 total points
ID: 1162831
Thank you

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question