-
Notifications
You must be signed in to change notification settings - Fork 220
Conversation
I agree completely with the intent -- ideally we have no warnings at least on the most popular platforms. I don't currently have a windows box to test the In regard to the casts for the timeval struct, the fields differ between platforms -- the change you made is the correct cast for BSD and, I assume, OSX, but on linux both fields are type |
Note that MSVC throws at least 6 warnings when compiling this for x64, due to conversion between SOCKET (which is a typedef for uint_ptr) and int. There's also an issue that MSVC maps WSAAddressToString to the wide (Unicode) version, causing crashes. Fixing it requires calling the 'A' variant explicitly: |
Hey. I thought I'd get to this sooner, but I haven't so I'm going to at least note here that your comments are well-received and I'll update the request at some point. |
OK, updated. Regarding implicit casting, I simply disabled the MSVC warning for that code. I think this is the best match for the concerns raised. For x64, I couldn't reproduce the warnings. This confuses me, because I know I've seen the WSAAddressToString before. For that one, I know the build description can set a preprocessor definition to get rid of the warning. Not sure what to do about the SOCKET/int casting because I haven't come across it. I think this is OK. This PR is not designed to eliminate all warnings. It's an ongoing effort. The warnings addressed here were troublesome to me, so I got rid of them. I think it's a step in the right direction. |
SOCKET is an intptr_t on Windows, so you will only get the cast warning on an x64 build. I'm using MSVC 2013 for what it's worth. Maybe earlier versions didn't warn for this? I know I'm not using a particularly high warning level (/W3) The WSAAddressToString issue is easily fixed by explicitly calling WSAaddressToStringA(). If not, and UNICODE is defined (which MSVC does by default), it won't just generate a warning, it will crash (buffer overflow due to writing a UTF-16 string to a char buffer). |
Yes, I remember the WSAAddressToString issue better now. I think with the further updated change, now a build description can set a preprocessor define to remove a warning. And I think this is the smallest evil. For whatever reason, I still don't get that warning I'm thinking of. |
Hey, sorry for the slow response. I was hoping to be able to test some of the changes using MinGW under windows, but unfortunately my only windows computer has decided to no longer function so I can't test how these changes effect it. Concerning the changes the Regarding the other changes I don't see myself being able to test them in MSVC in the near future, nor do I know when I will have windows available such that I can test the changes with MinGW. I get the feeling that the If you can test the changes with MinGW under windows and assure / change it such that there are no issues with |
Agreed about the ifdef. I'm not sure if _WIN32 means what it should mean, but I think this change is clearest about what dyad expects from its context. Agreed about pragmas. I mistakenly inferred MSVC was the only Windows compiler dyad was interested in supporting. My MSVC build is still warning free with this updated change. I ran |
I believe it was put in for 32bit windows, but still remains in 64bit windows for backwards compatibility. As I understand it its the surest way (or at least the most common) to identify windows regardless of compiler. All the changes look good. Thanks! |
I like having 0 warnings in a build....
I'm pretty confident with the _CRT_SECURE_NO_WARNINGS guard, which allows for specification of that directive outside, without creating a warning. I'm not sure if the second change can be more elegant.
Tested on Windows and Mac.