rng_58's blog

By rng_58, history, 7 years ago, In English

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?

  • Vote: I like it
  • +29
  • Vote: I do not like it

»
7 years ago, # |
  Vote: I like it +33 Vote: I do not like it

"However, it works only on Windows."

What other platforms do you need Cygwin to work on?

»
7 years ago, # |
  Vote: I like it +5 Vote: I do not like it

What about using ifdef to only inlclude it on Windows?

Like:

#ifdef _WIN32
#include <io.h>
#endif
»
7 years ago, # |
  Vote: I like it +5 Vote: I do not like it

MSDN says that _setmode requires io.h. So it looks like the way to go.

»
7 years ago, # |
  Vote: I like it +15 Vote: I do not like it

Testlib already includes <io.h> 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.

»
7 years ago, # |
Rev. 2   Vote: I like it +15 Vote: I do not like it

Try using -std=gnu++11 instead of -std=c++11 (or equivalent). It does the trick with my MinGW.

»
7 years ago, # |
  Vote: I like it +24 Vote: I do not like it

I've made a fix. Can you try the latest 0.9.14 version from the https://github.com/MikeMirzayanov/testlib ?