What is an alternative to including sys/times.h on windows?

↘锁芯ラ 提交于 2019-12-13 02:35:35

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!