Solved

TCHAR.H Equivalent on UNIX enviroment

Posted on 2003-11-08
10
2,386 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
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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
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 clear a vector as well as how to detect empty vectors in C++.

790 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