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
Solved

TClass, CClass, WClass ?!?

Posted on 1998-04-21
8
231 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
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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
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 be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

808 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