[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

TCHAR.H Equivalent on UNIX enviroment

Posted on 2003-11-08
10
Medium Priority
?
2,459 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 86

Accepted Solution

by:
jkr earned 1000 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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

649 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