"Const long * _ w64" is converted to "const time_t *" during Winpcap transplantation.

Source: Internet
Author: User

The error occurs in the following sentence:

Struct TM * ltime;
Char timestr [16];
Ltime = localtime (& header-> TS. TV _sec );

Error message:

Error c2664: "localtime": the parameter 1 cannot be converted from "const long * _ w64" to "const time_t *"


In vc6.0, time_t is defined:
Typedef long time_t;
It is actually long, so it can be used universally.

But in vs2005, it is different:
How to define _ use_32bit_time_t?
Typedef _ time64_t time_t;
Typedef _ int64 _ time64_t;
That is to say, time_t is a 64-bit integer.

Add _ use_32bit_time_t to the "pre-processing definition" in 'C/C ++ 'of the Project attribute to directly use long time.

Of course, we 'd better take yourCodeChanged:
Struct TM * date_tm;
Time_t time;

Time (& time );
Date_tm = localtime (& time );

In this way, you can use it.

[Thank you for your reference]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.