Borland c++ 里面线程如何睡眠?
我用Borland c++ 4.5.1
想在一个函数里实现线程睡眠
用到了:
Sleep(50);
编译出错,提示:
Error APPSVR\DATAMAN\WRNMATCH.CPP 249: Call to undefined function 'Sleep' in function ....
我加上:
#include <winbase.h>
编译提示
Error C:\BC45\INCLUDE\WINBASE.H 236: , expected
Error C:\BC45\INCLUDE\WINBASE.H 237: , expected
Error C:\BC45\INCLUDE\WINBASE.H 240: , expected
Error C:\BC45\INCLUDE\WINBASE.H 241: , expected
Error C:\BC45\INCLUDE\WINBASE.H 372: Type name expected
Error C:\BC45\INCLUDE\WINBASE.H 372: Declaration missing ;
Error C:\BC45\INCLUDE\WINBASE.H 386: Bit fields must have integral type
Error C:\BC45\INCLUDE\WINBASE.H 387: Bit fields must have integral type
Error C:\BC45\INCLUDE\WINBASE.H 388: Bit fields must have integral type
Error C:\BC45\INCLUDE\WINBASE.H 389: Bit fields must have integral type
Error C:\BC45\INCLUDE\WINBASE.H 390: Bit fields must have integral type
Error C:\BC45\INCLUDE\WINBASE.H 391: Bit fields must have integral type
Error C:\BC45\INCLUDE\WINBASE.H 392: Bit fields must have integral type
Error C:\BC45\INCLUDE\WINBASE.H 393: Bit field too large
Error C:\BC45\INCLUDE\WINBASE.H 393: Bit fields must have integral type
Error C:\BC45\INCLUDE\WINBASE.H 396: Multiple declaration for 'COMSTAT'
Error C:\BC45\INCLUDE\WINBASE.H 424: Bit fields must have integral type
Error C:\BC45\INCLUDE\WINBASE.H 425: Bit fields must have integral type
Error C:\BC45\INCLUDE\WINBASE.H 426: Bit fields must have integral type
Error C:\BC45\INCLUDE\WINBASE.H 427: Bit fields must have integral type
Error C:\BC45\INCLUDE\WINBASE.H 428: Bit fields must have integral type
Error C:\BC45\INCLUDE\WINBASE.H 429: Bit fields must have integral type
Error C:\BC45\INCLUDE\WINBASE.H 430: Bit fields must have integral type
Error C:\BC45\INCLUDE\WINBASE.H 431: Bit fields must have integral type
Error C:\BC45\INCLUDE\WINBASE.H 432: Bit fields must have integral type
Error C:\BC45\INCLUDE\WINBASE.H 432: Too many error or warning messages
[解决办法]
Sleep是Windows API函数。sleep才是C函数。
[解决办法]
先确认一下你是什么工程,Windows下的应用么?
[解决办法]
把你的头文件和单元文件内容贴出来看看。
[解决办法]
BCB 6没有这个问题
[解决办法]
看起来没什么问题。
#include <classlib\listimp.h>
这是什么?
------解决方案--------------------
Borland c++ 4.5.1
这个太古老了,没有环境,无法测试咯。
[解决办法]
为什么不用CB6试一试呢?而且CB编译时候确实会产生一些奇怪的问题,可以考虑换个电脑或文件目录试一试