OSGeo / gdal

GDAL is an open source MIT licensed translator library for raster and vector geospatial data formats.
https://gdal.org
Other
4.8k stars 2.51k forks source link

Referencing to the function isatty without any compiler/OS protection. Error on Visual Studio #2647

Closed mariopettinati closed 4 years ago

mariopettinati commented 4 years ago

Expected behavior and actual behavior.

Some apps are referencing the function isatty without any compiler/OS protection. This results in error when compiling in Visual Studio.

The library is correctly built, but for some executables we get an error

Examples: apps/gdaltransform.cpp:344 apps/gdallocationinfo.cpp:233

Steps to reproduce the problem.

Just start the compilation using Visual Studio.

Edit 1: I used the following command line nmake -f makefile.vc MSVC_VER=1910 DLLBUILD=1 WIN64=1 VERSION=310

Also attaching the nmake.local file with local 3rd party. Renaming it to .txt so it can be uploaded nmake.local.txt

Edit 2:

This is the error message:

gdaltransform.cpp The GEOS C++ API is unstable, please use the C API instead HINT: #include geos_c.h c:\temp\inpe\deps\build\terralib-3rdparty-msvc17\terralib-3rdparty-msvc17\gdal-3.1.0\apps\gdaltransform.cpp(344): error C3861: 'isatty': identificador nƯ encontrado

The message in English would be: 'isatty': Identifier not found

Operating system

Windows 10 - Visual Studio 2017 (Community Version)

GDAL version and provenance

3.1.0 - stable

rouault commented 4 years ago

Well, we do have succesful Visual Studio builds : https://ci.appveyor.com/project/OSGeo/gdal/history

There must be something different in the way you invoke yours compared to those ones

rouault commented 4 years ago

Please give more elements on how you reproduce the issue exactly, and the exact compilation error messages emitted

mariopettinati commented 4 years ago

I've made some additions to the description of this issue:

The library have been correctly built in release and in debug. The issue is related to two executables that are built after the library

Maybe it has something to do with the way that I am building it. Using this command line and this nmake.local, I'm getting this same error message regarding to the use of the 'isatty' function, that is not present in VS library

rouault commented 4 years ago

I'm wondering if there is not a "io.h" (which is the header where isatty() is defined in Windows) in your include path that would conflict with the Visual Studio one. Can you check that ?

mariopettinati commented 4 years ago

I'll try to check that. I'll look for this function in this file from VS library.

My VS version is the community one. I added this info to the description

mariopettinati commented 4 years ago

Indeed the function is there. Is is protected by some defines, but it is there. I even opened one project that I have here, added the include and the funcition call, and it built.

You are probably right. It must be a problem related to my environment when trying to find the correct implementation of "io.h". I'll invest more time on it.

Or maybe there is some related with deprecation. This function is protected by some definitions: For example, _CRT_NONSTDC_DEPRECATE and_CRT_INTERNAL_NONSTDC_NAMES

Maybe in that build context some of these defines are enable or disabled in a way that the isatty function gets hidden.

I'm terrible sorry for taking your time. May I close the issue or you do it?