|
From: Keith M. <kei...@us...> - 2017-04-09 21:50:04
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 09/04/17 00:57, Anton Shepelev wrote: > I am trying to compile babl, which relies on the strtok_r function: > > https://manned.org/strtok.3 > > but it seems absent in MinGW. Will it be correct to add it? strtok_r() is a POSIX.1 function, not ISO-C; thus providing it goes beyond the MinGW remit of providing "extensions to support ISO-C99". That said, if you are prepared to restrict your application to Vista or later, (or link with non-free MSVCR80.DLL or later), Microsoft do provide the syntactically equivalent, (in all but name), and mostly functionally equivalent strtok_s(), so you could simply: #define strtok_r strtok_s That should work with MinGW; the entry point is already defined in libmsvcrt.a, but a potential problem could be that <string.h> does not (yet) declare a corresponding prototype -- a formal bug report, to remind me to add it[1], would be helpful. Of course, if you adopt this approach while linking with MSVCRT.DLL, then your application will not run on any WinXP or earlier host; (it will abort with a "DLL entry point not found" exception. It would be possible to mitigate this, if there is sufficient user demand, by providing a (likely simple) MinGW implementation of strtok_r(); this would necessitate a formal feature request ticket[2]. [1]: We already have https://sourceforge.net/p/mingw/bugs/1922/, but it's much too vague; we need a ticket which explicitly names each "_s" suffixed function for which a prototype is required. [2]: https://sourceforge.net/p/mingw/bugs/new/ - -- Regards, Keith. Public key available from keys.gnupg.net Key fingerprint: C19E C018 1547 DE50 E1D4 8F53 C0AD 36C6 347E 5A3F -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.20 (GNU/Linux) iQIcBAEBAgAGBQJY6qyDAAoJEMCtNsY0flo/KDMP/iYqCUyqU1gnYHGZWn597XG4 2B3HjnBFqY+JjDd+TnHa9QLEAljzZVr3YR1jdsHv1w8edlW3wiUwBhTf1AWT2Dle UXa6xcaPB1PYHkzUwGRgU+vnWpchr75i8SRf7holh1h1yAsl8j86tbQkoBcdXlQS +XjNutM3hpdxCQNnwCF7lGwGtykLbqafLMXfH+8jGFfm4n4KSvVUy3ejce+6AEuG AKKGKv9Py5Rjz9p0f/zWjyxD7SVQU0zL1L44sWVC+r9d+VTvLmqODX57D+7EZ9jD JHEB7XervrmnmItg3008TRFgAxyhwV5MhsnJd3EWsVnpa5o0m1o3xZxskSUSTXNT Uqp0KJXGZ7LvP/CEdWxOn4E4VxjbUudX4MrUzrWXCR4xTNpaKwerOI+U/O27O4Qh P5K9xeSc5wBKnJ3bpVadEpWucSMVmKQITsvYU7/ViEv7/rLTS0tziQ6rx08FF7pP Ov1fALH+p6t6vFA5ac9ipXOsVe5jNow5v8tiQOuNr/hzr/k3EmVtAeLPHr3O3wEj O3+IqrSUBwBcQIFB1cYnR3CrsastPgicxdt+fJ3RnafFuz0QiE0KnklhBue6X+Xn pXQQZSCOdGVu187Qg341w1VsYpt2FNBrkR3Ajdg2yojkGT7nHwc2jh7aN25hpeY2 I2VKCpodDJlefnrF4a0H =n68w -----END PGP SIGNATURE----- |