Solved

TCHAR.H Equivalent on UNIX enviroment

Posted on 2003-11-08
10
2,423 Views
Last Modified: 2009-02-20
I am using FORTE 6.0 Compiler on Solaris. I am porting a windows module to UNIX but I am facing a problem in defining _T(x) macro and TCHAR types - may be other definitions found in TCHAR.H as well.
How can I resolve this situation? Can I define those types locally? Is there is any other easier and faster solution?
0
Comment
Question by:arabolla
[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
  • 4
  • 3
  • 3
10 Comments
 
LVL 6

Expert Comment

by:GaryFx
ID: 9707003
You can certainly define those yourself, and it's pretty trivial.  Just set up a .h file that chooses between Unicode and conventional characters:

  #if defined (UNICODE)
      #define _T(x)  L ## x
      // Additional unicode defines go here
  #else
      #define _T(x) x
      // Additional non unicode defines go here
  #endif


Then just keep adding definitions as needed.  

(I'm deliberately sidestepping the idea of just copying Microsoft's tchar.h because of the copyright issues involved, but I'm sure many people do that, and it's probably de minimis.)

Gary
0
 

Author Comment

by:arabolla
ID: 9707683
What is the definition of L ## x ? It is still giving errors.
0
 
LVL 6

Expert Comment

by:GaryFx
ID: 9707717
## is the preprocessor paste operation.  Thus _T("foo") should be replaced by the preprocessor with L"foo", which generates a wide string literal.

What exactly is the error message?  (In general, whenever you need to ask here about a compiler error message, you're well advised to paste the first one or two compiler messages into your posting.)

Gary
0
Independent Software Vendors: 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!

 
LVL 86

Accepted Solution

by:
jkr earned 250 total points
ID: 9707744
If you want to save you some manual work, get the Cygwin environment from cygwin.redhat.com and copy the relevant part from the (free) header files.
0
 
LVL 86

Expert Comment

by:jkr
ID: 9707778
Thanx, but that is not really fair towards GaryFx who gave you the actual solution - I just told you how to save some work on this...
0
 

Author Comment

by:arabolla
ID: 9707802
I appreciate Gary's comment of course, however, I have found the direct solution in the cygwin version which compiled straight forward, this is the criteria for accepting solutions, isn't it?
Gary, Thanks. Still more questions to go, lots of points in hand!
0
 
LVL 6

Expert Comment

by:GaryFx
ID: 9708913
You do understand that by using the cygwin tchar, your code is now bound by the license (which is either GPL or LGPL, I'm not sure which).  That could be an issue for you, as it forces you to make your code open source.

Gary
0
 
LVL 86

Expert Comment

by:jkr
ID: 9708927
Nope, that applies to extending OSS projects (altering code etc.). You are not altering anything if you use GPL headers - if not, as a result, all SW compiled with GCC would have to be OSS.
0
 

Author Comment

by:arabolla
ID: 9709333
I agree with jkr. I have no obligation of any kind if I used the headers and/or GNU products with no altering.
0
 
LVL 6

Expert Comment

by:GaryFx
ID: 9709623
It appears they've changed the libstdc++ license from the vanilla or older GPL to the GPL with a special runtime exception.  My memory was correct to the extent that libstdc++ is not under the LGPL.  One would expect it to use that, since it is, after all, a library.  But it isn't specifically because of the way templates work - you get the benefit of the code without having to use an object library generated directly from the licensed code.  

It used to be the case that if you instantiated a template from the GNU libstdc++, you bound your entire program - which forced a careful reading to see if other uses also applied.  I'm glad to see they've simplified that.

Gary
0

Featured Post

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!

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
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…
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 technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

696 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