Solved

TCHAR.H Equivalent on UNIX enviroment

Posted on 2003-11-08
10
2,377 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
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
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 viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
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.

770 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