问题
Background
I am trying to compile some code on windows that has previously been compiled on QNX. According to this SO Question and this SO Question, I can resolve this issue by simply removing the include statements for sys/times.h. When I remove the includes, I get a bunch of errors saying that variables have not been defined within the scope. I assume this is because I have removed the include call.
Question
What is an alternative to using sys/times.h in the code so I can use it on windows?
Attempted Solutions
- Download & install cygwin to compile code - I cannot download cygwin due to network restrictions. I would prefer not to have to download cygwin on my home network
回答1:
Here's how one project solved the problem:
https://code.google.com/p/madp-win/source/browse/src/include/sys/times.h?r=4ef496e2071896b295262c89eb36a8b3d7656bae
They use various includes available on Windows to fill in most of it, and define the rest themselves. You may have to dig in the codebase a bit if you want to see the implementations for the other two functions - note that the library is LGPL.
回答2:
According to the questions you linked sys/times.h
is only supported in cygwin and not in MinGW. They also indicate that if you can't use cygwin your only recourse is to rewrite the calls to use a standard Windows API instead, and remove the include of sys/times.h
.
来源:https://stackoverflow.com/questions/24741553/what-is-an-alternative-to-including-sys-times-h-on-windows