QB64.org Forum
Active Forums => QB64 Discussion => Topic started by: EricE on March 25, 2020, 05:26:22 pm
-
The cpp time function gets the number of seconds since 00:00 hours, Jan 1, 1970 UTC.
http://www.cplusplus.com/reference/ctime/time/?kw=time (http://www.cplusplus.com/reference/ctime/time/?kw=time)
The function prototype is:
time_t time (time_t* timer);
According to the QB64 documentation for Using _OFFSET,
http://www.qb64.org/wiki/Using_OFFSET (http://www.qb64.org/wiki/Using_OFFSET)
we should be able to call the time function in QB64 by declaring it as:
Compiling this test program fails. What am I doing wrong?
time_now1&&
= time&&
(_OFFSET(time_now2&&
))
-
I changed it to DECLARE CUSTOMTYPE LIBRARY and it compiled and ran. I'm not a cpp dude, so I don't know if the info it gave is correct. But it compiled after that change.
- Dav
-
Thank you Dav, it does indeed work now.
I wonder how I missed using CUSTOMTYPE in the documentation?
Actually, what does CUSTOMTYPE do?
The time value returned looks correct.
Here is a website that will give the unix time stamp for comparison.
https://www.unixtimestamp.com (https://www.unixtimestamp.com)
time_now1&&
= time&&
(_OFFSET(time_now2&&
))
-
Found this comment in the release notes for QB64 v0.94.
-DECLARE CUSTOMTYPE LIBRARY, allows you to override the required types and use the variable types you want, provided they are the same size
This makes sense as the compiler error messages that were being raised indicated an incompatibility between the time&& declared parameter type and the cpp type "time_t".