Search code examples
ceclipsegcccygwin

Eclipse project cannot include tchar.h


I am trying to build an lzmat_lib compression library using Eclipse with Cygwin gcc. I downloaded the library from the link http://www.matcode.com/lzmat_lib.zip. The file has the following include files:

#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <tchar.h>
#include "lzmat.h"

It cannot find the tchar.h header file. I do not understand how to add this header file. Please suggest a solution.


Solution

  • Your options are to install a Windows development environment, like Visual Studio or mingw along with the Windows SDK, or to port the code to your cygwin (posix) environment.

    To port the code, you'd just do this:

    1. Remove #include <tchar.h>.

    2. Search and replace _TCHAR to char.

    3. Search the file for all strings beginning with _t and remove that prefix. E.g., _tfopen becomes just fopen. _tprintf becomes printf.

    4. Search for the text _T and remove it. You could also remove the extra parentheses that will then surround your string.

    5. Deal with any other issues as they come up by removing the dependency on tchar.h and using a standard function instead.