[Please don't top post on this list.] On 8/3/2019 5:02 PM, Denis Vnoukov wrote: > Yes, gcvt is legacy. But there is no one Linux distribution which has no gcvt > in > the world. > Moreover gcvt present into MSVC, Intel C, mingw, etc.. > It is true to have gcvt with right declaration. > FD_ZERO(&read_fd); <== with -Wold-style-cast produced real bogus and > suspicious > warning which looks like bug > GetTickCount64(); <== recommended part of WINAPI and must be avail via > windows.h > _BitScanReverse64 and _BitScanForward64 must be with "unsigned long *": > unsigned char _BitScanForward64( > unsigned long * Index, > unsigned __int64 Mask > ); > due to ms specification as well...
There are several mistakes (not GCC bugs) in your program. 1. As I already said in my first message, you need to define the appropriate feature-test macro in order to get the declaration of gcvt. (I suggested defining _XOPEN_SOURCE to 500, and that in fact works.) 2. The Microsoft documentation for GetTickCount64 says, "To compile an application that uses this function, define _WIN32_WINNT as 0x0600 or later." You didn't do this. 3. The Microsoft documentation for _BitScanForward64 says that the first argument is of type 'unsigned long *'. You assumed that Microsoft's unsigned long would be the same size as Cygwin's. You can avoid this problem by using ULONG instead of unsigned long. I'm attaching a fixed version of your program that compiles without warnings and runs without crashing on 64-bit Cygwin. Ken
#define _XOPEN_SOURCE 500 #define _WIN32_WINNT 0x0600 #include <stdlib.h> #include <stdio.h> #include <sys/select.h> #include <windows.h> #include <stdint.h> #include <intrin.h> int main() { char buf[50]; char * str = gcvt (3.141592653589793238462643383279502884197169399375, 49, buf); printf ("buffer: %s", str); fd_set read_fd; FD_ZERO (&read_fd); GetTickCount64 (); ULONG index; uint64_t b = 0xbedabedadeadc0de; _BitScanForward64 (&index, b); _BitScanReverse64 (&index, b); return 0; }
-- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple