### rng_58's blog

By rng_58, history, 11 months ago, ,

Does anyone use testlib on cygwin + g++?

It gives a compilation error at the 434th line:

_setmode(_fileno(file), O_BINARY); 

I know two ways to fix this issue:

• Comment out the 434th line. However, it disables this line and I'm not sure whether this is a good way.

• Add <io.h> to testlib. However, it works only on Windows.

How to fix the compilation error in a better way?

•
• +29
•

 » 11 months ago, # |   +33 "However, it works only on Windows."What other platforms do you need Cygwin to work on?
 » 11 months ago, # |   +5 What about using ifdef to only inlclude it on Windows?Like: #ifdef _WIN32 #include #endif 
 » 11 months ago, # |   +5 MSDN says that _setmode requires io.h. So it looks like the way to go.
•  » » 11 months ago, # ^ |   +5 Following purely MSDN in Cygwin might not be the best idea as it has it's own logic for handling binary and text files https://cygwin.com/cygwin-ug-net/using-textbinary.html#textbin-devel .
 » 11 months ago, # |   +15 Testlib already includes for windows except cygwin is somewhere between so current ifdefs probably don't detect it as such and you probably don't need to include other windows junk in cygwin.
 » 11 months ago, # | ← Rev. 2 →   +15 Try using -std=gnu++11 instead of -std=c++11 (or equivalent). It does the trick with my MinGW.
 » 11 months ago, # |   +24 I've made a fix. Can you try the latest 0.9.14 version from the https://github.com/MikeMirzayanov/testlib ?
•  » » 11 months ago, # ^ |   +20 Thank you, it works now.