wince下不支持time()

来源:互联网 发布:智商高女生 知乎 编辑:程序博客网 时间:2024/05/21 09:40

居然wince下不支持time()的调用了,没有实现lib,
今天花了3个小时才居然发现,浪费时间呀

现在的办法是调用CTime::GetCurrentTime()或windows API GetSystemTime()

 

 

如果在用VC++写WinCE时,用到time(time_t *)这个比较经典的时间函数时,编译器会报出"error LNK2019: 无法解析的外部符号 __imp_time,该符号在函数……"的错误,在google上搜了很久,没什么进展.最后在国外的一个博客中找到了答案.

If u got the following error when trying to compile an WindowCE application

"error LNK2019: unresolved external symbol __imp_time referenced in function"
that is because functions in time.h is not implemented on Window CE.
The problem is described below:
"Since my last post was time related, why not another? Don't worry too much about why this is on a Networking Blog even though it has nothing to do with networking. I own this stuff since there's a lot of technology in CE and not a ton of developers, so we get to cover all sorts of ground. And I'm not inclined to create a "cetime" blog to cover time related functions on CE :smile:.
Once in a while I'm asked on a newsgroup or internally someone wants to use a Unix style "time.h" function for whatever reason. The answer here is sorry, no, this isn't supported. In order to save resources (both ROM and developer), we decided only to implement Win32 time related functions.
However, it's not quite that simple. We do ship time.h in %_WINCEROOT%/public/ie/sdk/inc. This because some code we've ported from the desktop needs the time related structures, though it obviously can't use the Unix style functions declared in this file since they're not implemented anywhere. (The main data structure people use is tm, not to be confused with Toastmasters (which is a wonderful organization by the way).)
This causes problems for developers who are using Intellisense. Intellisense sees the C runtime functions defined in time.h and doesn't realize that they're not implemented, so people write code that calls into them and their code compiles but they get link errors. Understandably this is frustrating. The workaround here is obviously not to trust Intellisense for this particular case. For future versions, we're looking at removing time.h from this source place or at a minimum removing all the Unixy functions like time(), gmtime(), localtime(), etc... so Intellisense doesn't get confused.


原来是time.h在WinCE中不能用造成的.用CTime代替吧...

原创粉丝点击