Solved

TClass, CClass, WClass ?!?

Posted on 1998-04-21
8
229 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
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 22

Expert Comment

by:nietod
Comment Utility
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
Comment Utility
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
Comment Utility
Namespaces are supported by MSVC (verified in version 4.2) and Borland (verified in BC++ version 5.02)
0
 

Author Comment

by:gavinpat
Comment Utility
Edited text of question
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:gavinpat
Comment Utility
Edited text of question
0
 
LVL 22

Expert Comment

by:nietod
Comment Utility
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
Comment Utility
Come and get those points Alexo!

0
 
LVL 11

Accepted Solution

by:
alexo earned 50 total points
Comment Utility
Thank you
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
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 video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now