Solved

TCHAR.H Equivalent on UNIX enviroment

Posted on 2003-11-08
10
2,354 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
  • 4
  • 3
  • 3
10 Comments
 
LVL 6

Expert Comment

by:GaryFx
Comment Utility
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
Comment Utility
What is the definition of L ## x ? It is still giving errors.
0
 
LVL 6

Expert Comment

by:GaryFx
Comment Utility
## 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
 
LVL 86

Accepted Solution

by:
jkr earned 250 total points
Comment Utility
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
Comment Utility
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:arabolla
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at 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 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.

763 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

11 Experts available now in Live!

Get 1:1 Help Now