tchar.h: Missing Macro _putts (and function _putws)

Started by Fuerst, January 31, 2026, 06:57:03 PM

Previous topic - Next topic

Fuerst

compiling the source below, you get the following compiler-error because in tchar.h, the macro _putts is missing.

O:\Sources\test2\test2.c(21): warning #2018: Undeclared function '_putts' (did you mean: fputws?); assuming 'extern' returning 'int'.
 _putts(_T("Hello World"));


--- Source

#define _UNICODE

#define WORKAROUND
#undef WORKAROUND

#include <stdio.h>
#include <tchar.h> // missing _putts() (and _putws)

#if defined WORKAROUND
    /* function _putws() missed although */
#   if defined _UNICODE
#      define _putws(s) {_fputts((s), stdout); _fputts(_T("\n"), stdout); }
#       define _putts(s) _putws(s)
#   else
#      define _putts(s) puts(s)
#   endif
#endif

int main(void)
{
   _putts(_T("Hello World"));
}

Vortex

#1
msvcrt.dll exports the function _putws. Creating the import library :

\PellesC\bin\polib /OUT:msvcrt.lib /MACHINE:x86 C:\Windows\System32\msvcrt.dll
#include <stdio.h>

extern int _putws(const wchar_t *str);

int main(void)
{
    _putws(L"This is a _putws test.");
    return 0;
}
Code it... That's all...

Pelle

I guess this should be fixed for compatibility, but <tchar.h> hasn't been interesting since people stopped supporting Windows NT and Windows 9X (which in my book was right after the stone age... ;) )
/Pelle

Fuerst

The technology helps me to maintain a console program that determines and outputs metadata for files (including file names containing non-ASCII characters) under both Windows and UNIX/Linux.