Solved

TClass, CClass, WClass ?!?

Posted on 1998-04-21
8
236 Views
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
0
Comment
Question by:gavinpat
[X]
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
8 Comments
 
LVL 22

Expert Comment

by:nietod
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...)  
0
 
LVL 5

Expert Comment

by:yonat
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"
#else
#error "unknown compiler"
#endif
0
 
LVL 11

Expert Comment

by:alexo
ID: 1162826
Namespaces are supported by MSVC (verified in version 4.2) and Borland (verified in BC++ version 5.02)
0
Industry Leaders: 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

by:gavinpat
ID: 1162827
Edited text of question
0
 

Author Comment

by:gavinpat
ID: 1162828
Edited text of question
0
 
LVL 22

Expert Comment

by:nietod
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.
0
 

Author Comment

by:gavinpat
ID: 1162830
Come and get those points Alexo!

0
 
LVL 11

Accepted Solution

by:
alexo earned 50 total points
ID: 1162831
Thank you
0

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

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
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.

729 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