Блог пользователя rng_58

Автор rng_58, история, 6 лет назад, По-английски

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
  • Проголосовать: не нравится

»
6 лет назад, # |
  Проголосовать: нравится +33 Проголосовать: не нравится

"However, it works only on Windows."

What other platforms do you need Cygwin to work on?

»
6 лет назад, # |
  Проголосовать: нравится +5 Проголосовать: не нравится

What about using ifdef to only inlclude it on Windows?

Like:

#ifdef _WIN32
#include <io.h>
#endif
»
6 лет назад, # |
  Проголосовать: нравится +5 Проголосовать: не нравится

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

»
6 лет назад, # |
  Проголосовать: нравится +15 Проголосовать: не нравится

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.

»
6 лет назад, # |
Rev. 2   Проголосовать: нравится +15 Проголосовать: не нравится

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

»
6 лет назад, # |
  Проголосовать: нравится +24 Проголосовать: не нравится

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