Re: Using isatty() on WIN32 platform

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Using isatty() on WIN32 platform
Дата
Msg-id 32143.1511207604@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Using isatty() on WIN32 platform  (Martín Marqués <martin@2ndquadrant.com>)
Ответы Re: Using isatty() on WIN32 platform
Список pgsql-hackers
Martín Marqués <martin@2ndquadrant.com> writes:
> While following suggestions from Arthur Zakirov on a patch for
> pg_basebackup I found that we are using isatty() in multiple places, but
> we don't distinguish the WIN32 code which should use _isatty() as per [1].

I dunno, [1] looks like pure pedantry to me.  Unless they intend to stop
conforming to POSIX at all, they aren't going to be able to remove the
isatty() spelling.

Moreover, I don't think that isatty() is the only function name at issue.
I found this at:
https://docs.microsoft.com/en-us/cpp/c-runtime-library/compatibility
   The C++ standard reserves names that begin with an underscore in the   global namespace to the implementation.
Becausethe POSIX functions   are in the global namespace, but are not part of the standard C   runtime library, the
Microsoft-specificimplementations of these   functions have a leading underscore. For portability, the UCRT also
supportsthe default names, but the Visual C++ compiler issues a   deprecation warning when code that uses them is
compiled.Only the   default POSIX names are deprecated, not the functions. To suppress the   warning, define
_CRT_NONSTDC_NO_WARNINGSbefore including any headers   in code that uses the original POSIX names.
 

If you're seeing warnings from use of isatty(), I'd be inclined to think
about dealing with it by adding #define _CRT_NONSTDC_NO_WARNINGS,
rather than trying to individually #define every affected function.

> Attached is a patch for src/include/ports/win32.h

FWIW, if we do adopt that, I think it should now go into win32_port.h.
In either case, though, seems like it might be problematic to have
such a #define before including whatever file Microsoft's definition
lives in.
        regards, tom lane


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Martín Marqués
Дата:
Сообщение: Re: [HACKERS] pg_basebackup --progress output for batch execution
Следующее
От: Brian Cloutier
Дата:
Сообщение: Re: Add PGDLLIMPORT lines to some variables