-
Notifications
You must be signed in to change notification settings - Fork 64
Fix use of undefined pointer types in definitions #78
base: master
Are you sure you want to change the base?
Conversation
e9b54f8
to
077d92c
Compare
Whole header because of 1 small structure?! Possible implementation:
just for info, unused structure is also small:
I think, if function is replacement - it should replace everything. |
Is there a push to remove Winsock2.h, who understands its meaning? There may be missing instructions to write to CMakeLists.txt. However, care to |
We could just make our own function that returns the time specification we want. For instance, obs uses os_gettime_ns which wraps over platform specifics. Here's an example of a similar function in action:
to
I'm not sure the wanted precision of the clock so I guess that could be nanoseconds above and then just convert on the fly to whatever measurement wanted, perhaps make some convenience functions to do so. I'm also not sure how involved that is to change so maybe take the suggestion with a grain of salt. |
Wait as I will do 2 points. 1.To check the bad influence when adding Winsock 2.h to the header file. 2.To find the resolution of the time that is really needed. |
I am also looking forward to the removal of this dependence on MSVC semantics, and likely standards non-compliant code, but defining a struct in a function declaration is quite the edge case. Personally, these changes simply make the code compile on clang-cl, so there is little gain in delaying it to resolve the pre-existing bugs. |
This coincidentally also adds support for clang-cl. There's two problems being solved here.
The types
timeeval
andtimezone
are not defined where they're used in the gettimeofday.h headertimezone
isn't defined by the WinAPI headers anywhere.timeeval
is only defined in Winsock2.h.The implementation of
gettimeofday()
here doesn't actually use thetimezone
structure so it may be defined as an opaque pointer without definition.timeeval
is used however so it must have a definition, so we must include Winsock2.h in the header. Since the definition in the header didn't originally have a type associated with it, it could be interpreted as a different type from that of the one provided by WinSock2.h. clang-cl believes it to be an anonymous structure in the header so it thinks the function type is different between header declaration and implementation.