“sys/time.h” Replacement for Windows

本文提供了一种针对GNU编译器家族中sys/time.h头文件在Windows平台上的替代实现,包括三个主要文件:time.h、times.h及times.cpp。此替代方案使原本依赖于该头文件的C/C++代码能够在Windows环境下成功编译。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

https://www.codefull.org/2015/12/systime-h-replacement-for-windows/

Some C/C++ code targeted for GNU family compilers fail to compile under Windows due to the dependency on sys/time.h header file. The repository here has provided a neat implementation for it. Basically you need these three files: time.htimes.h and times.cpp. I have included them here (in case the repository ever went dead). Note that this is not my code and the original license of the code was LGPL.

sys/time.h:

sys/times.h:

sys/times.cpp:

 

 

lientek@ubuntu16:~/linux/IMX6ULL/Linux_Drivers/1_chrdevbase$ make make -C /home/alientek/linux/IMX6ULL/linux/alientek_linux/linux-imx-rel_imx_4.1.15_2.1.0_ga M=/home/alientek/linux/IMX6ULL/Linux_Drivers/1_chrdevbase modules make[1]: Entering directory '/home/alientek/linux/IMX6ULL/linux/alientek_linux/linux-imx-rel_imx_4.1.15_2.1.0_ga' CC [M] /home/alientek/linux/IMX6ULL/Linux_Drivers/1_chrdevbase/chrdevbase.o In file included from ./arch/x86/include/asm/bitops.h:16:0, from include/linux/bitops.h:36, from include/linux/kernel.h:10, from include/linux/list.h:8, from include/linux/module.h:9, from /home/alientek/linux/IMX6ULL/Linux_Drivers/1_chrdevbase/chrdevbase.c:1: ./arch/x86/include/asm/arch_hweight.h: In function ‘__arch_hweight64’: ./arch/x86/include/asm/arch_hweight.h:53:42: error: expected ‘:’ or ‘’ before ‘POPCNT64’ asm (ALTERNATIVE("call __sw_hweight64", POPCNT64, X86_FEATURE_POPCNT ^ ./arch/x86/include/asm/alternative.h:125:28: note: in definition of macro ‘ALTINSTR_REPLACEMENT’ b_replacement(num)":\n\t" newinstr "\n" e_replacement(num) ":\n\t" ^ ./arch/x86/include/asm/arch_hweight.h:53:7: note: in expansion of macro ‘ALTERNATIVE’ asm (ALTERNATIVE("call __sw_hweight64", POPCNT64, X86_FEATURE_POPCNT ^ In file included from ./arch/x86/include/asm/pgtable_types.h:250:0, from ./arch/x86/include/asm/processor.h:18, from ./arch/x86/include/asm/thread_info.h:49, from include/linux/thread_info.h:54, from ./arch/x86/include/asm/preempt.h:6, from include/linux/preempt.h:18, from include/linux/spinlock.h:50, from include/linux/seqlock.h:35, from include/linux/time.h:5, from include/linux/stat.h:18, from include/linux/module.h:10,
最新发布
03-22
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值