Compile problem
naydef opened this issue · 9 comments
||=== Build: Release in *** (compiler: GNU GCC Compiler) ===|
C:\Users\Geo\Desktop\DBG\SteamServerQuery\termcolor.hpp||In function 'bool termcolor::_internal::is_atty(const ostream&)':|
C:\Users\Geo\Desktop\DBG\SteamServerQuery\termcolor.hpp|452|error: '_fileno' was not declared in this scope|
C:\Users\Geo\Desktop\DBG\SteamServerQuery\termcolor.hpp||In function 'bool termcolor::_internal::is_atty(const ostream&)':|
C:\Users\Geo\Desktop\DBG\SteamServerQuery\termcolor.hpp|454|warning: control reaches end of non-void function [-Wreturn-type]|
||=== Build failed: 1 error(s), 3 warning(s) (0 minute(s), 1 second(s)) ===|
Error lines:
//! Test whether a given `std::ostream` object refers to
//! a terminal.
inline
bool is_atty(const std::ostream& stream)
{
FILE* std_stream = get_standard_stream(stream);
#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX)
return ::isatty(fileno(std_stream));
#elif defined(TERMCOLOR_OS_WINDOWS)
return ::_isatty(_fileno(std_stream));
#endif
}
Compiler: TDM-GCC 4.9.2
IDE: CodeBlocks 16.01
Solution?
TDM-GCC is broken and outdated as all hell, I recommend using MSYS2 and GCC therefrom
@naydef Hm.. I think the problem is that TDM-GCC tries to be compatible with *nix api and provide those sort of headers. Could you please check whether it defines either __unix__
or __unix
macro? If so, please try to swap lines in OS detection code.
#if defined(__unix__) || defined(__unix) // that line wasn't first
# define TERMCOLOR_OS_LINUX
#elif defined(_WIN32) || defined(_WIN64)
# define TERMCOLOR_OS_WINDOWS
#elif defined(__APPLE__)
# define TERMCOLOR_OS_MACOS
#else
# error unsupported platform
#endif
No. They are not defined. The test code:
int main(int args, char *argv[])
{
//std::cout << termcolor::red <<"Welcome to Steam Server Query Tool v" << SSQ_VERSION; //<< termcolor::reset;
#ifdef __unix__
std::cout << "__unix__" << std::end;
#endif // __unix__
#ifdef __unix
std::cout << "__unix" << std::endl;
#endif // __unix
std::cout << "Hello" << std::endl;
return EXIT_SUCCESS;
}
Prints:
Hello
Process returned 0 (0x0) execution time : 0.024 s
Press any key to continue.
Replaced the code with the posted here and doesn't work. The same error
I'm pretty sure this is TDM-GCC's trashiness :G
@naydef please try to define it before including termcolor.hpp
. It seems like TDD-GCC provides Nix API, thought it's strange it doesn't setup __unix
macro.
The __unix
macro would break just about every non-trivial piece of code in existence
@ikalnitsky, What? Where to define it? Anyway, I will try with tdm-gcc 5.1.0
@naydef I'm not sure tdm-gcc 5.1.0
could fix that. It seems it doesn't have some implementation, or store them in other headers. I'm really sorry, I can't help ya now. I don't have any Windows machine near me. :(
I think the best thing you can do is to google where to find _fileno
function in that compiler.
You're right @ikalnitsky. Installed TDM-GCC 5.1.0
and now it compiles correctly and works. Thanks
I will close this issue