RandyGaul / cute_headers

Collection of cross-platform one-file C/C++ libraries with no dependencies, primarily used for games
4.25k stars 264 forks source link

[REQUEST] cf_time_t is not cross platform #202

Closed peppemas closed 4 years ago

peppemas commented 4 years ago

Actually on Windows Platform the struct contains this:

https://github.com/RandyGaul/cute_headers/blob/0a08c5a60a1d28d1c2451cb1e75de964bcff5e82/cute_files.h#L154-L157

Instead on Linux/Mac this:

https://github.com/RandyGaul/cute_headers/blob/0a08c5a60a1d28d1c2451cb1e75de964bcff5e82/cute_files.h#L185-L188

When you write code you are forced to check the platform:

cf_time_t time;
cf_get_file_time("myfile",&time); 

#ifdef _WIN32
   FILETIME t = time.time;
#else 
   time_t t = time.time;
#endif

It would be helpful to have a common structure with the same types and to do necessary conversions internally.

RandyGaul commented 4 years ago

What exactly is the problem?

When I use this header I wrote code like this:

cf_time_t now;
cf_get_file_time("myfile", &prev);

if (cf_compare_file_times(&prev, &now)) {
}

Time is hidden within a cross-platform struct.

RandyGaul commented 4 years ago

Closing this out, feel free to reopen or comment if needed!