Hi Devs,
I found some incompatibilities when I tried to compile our current code with MS Visual Studio 2010 and 2008, the oldest versions I have available. These incompatibilities were in different "classes" of warnings/errors:
1) compiler warnings
2) compilation errors
3) compile and build errors
Points 1 and 2 are "simple" but point 3 is annoying because vsscanf() is not available in older MSVC versions, but it exists in current versions.
So the question is: do we care about older MSVC versions than, say, VS 2015 (which is currently documented on the MS site) or what should be the oldest MSVC version we are supporting?
I don't know which version between VS 2010 and VS 2015 add vsscanf() support (VS 2015 has it).
The attached patch addresses the 'vsscanf' issue so I could build FLTK but it is definitely NOT a solution - it returns 0 rather than using a replacement function.
Comments and suggestions welcome. Patches with working replacement functions for vsscanf() would also be appreciated. Personally I don't feel comfortable writing such a patch and I don't have the time to do it.
Doh!I just *actually looked* at Albrecht's patch, and realised it is "vsscanf_l" that we need here, not "vsscanf"...
On 3/22/22 16:08 imacarthur wrote:
Doh!I just *actually looked* at Albrecht's patch, and realised it is "vsscanf_l" that we need here, not "vsscanf"...Thanks for your help!
Please don't take my (pseudo) patch too seriously. It may well be that we need vsscanf as well, but I'm not sure.
Fact is that the latest master contains code that can't be built with VS 2010 and earlier [1] because none of the vsscanf variants is available in these VS versions. I don't know about any versions between 2010 and 2015 [2]. The latter has it according to MS docs but docs of older MS versions don't seem to be available. Maybe in the web archive...
Please don't take my (pseudo) patch too seriously. It may well be that we need vsscanf as well, but I'm not sure.Hmm... I wasn't at all familiar with vsscanf_l, so went googling, and it rather looks like it might be a BSD'ism (and hence present in Darwin/macOS) but not generally available anyway - indeed our "Fl_UNIX_System_Driver" does not use it (only uses vsscanf) and I rather think that the WIN32 driver should not use it either... Though it would still need vsscanf.Fact is that the latest master contains code that can't be built with VS 2010 and earlier [1] because none of the vsscanf variants is available in these VS versions. I don't know about any versions between 2010 and 2015 [2]. The latter has it according to MS docs but docs of older MS versions don't seem to be available. Maybe in the web archive...Maybe so - I do not see vsscanf_l on the MSDN docs (though it looks like vsscanf is there for the current version) so in any case our code that uses _vsscanf_l looks likely to be wrong, even with the latest MS tools - unless someone knows different?
On Tuesday, 22 March 2022 at 15:39:15 UTC imacarthur wrote:
Hmm... I wasn't at all familiar with vsscanf_l, so went googling, and it rather looks like it might be a BSD'ism (and hence present in Darwin/macOS) but not generally available anyway - indeed our "Fl_UNIX_System_Driver" does not use it (only uses vsscanf) and I rather think that the WIN32 driver should not use it either... Though it would still need vsscanf.
[...] I do not see vsscanf_l on the MSDN docs (though it looks like vsscanf is there for the current version) so in any case our code that uses _vsscanf_l looks likely to be wrong, even with the latest MS tools - unless someone knows different?
So I went looking - and I'm now (pretty well) convinced that "vsscanf_l" is a BSD'ism and should not be in the Windows driver at all - it looks like our Windows implementation of clocale_sscanf() was largely cut'n'pasted from the Darwin/macOS version, whereas the Unix driver version could have been more appropriate.Or maybe even just...int Fl_WinAPI_System_Driver::clocale_sscanf(const char *input, const char *format, va_list args) {char *saved_locale = setlocale(LC_NUMERIC, NULL);setlocale(LC_NUMERIC, "C");int retval = vsscanf(input, format, args);setlocale(LC_NUMERIC, saved_locale);return retval;}Though even that assumes that at least vsscanf() is available -- which will not be the case in pre-2013 VS versions AFAICT.
All that aside, our clocale_sscanf() methods are all misnamed (we have 4 of them, in Fl_System_Driver, Fl_Unix_System_Driver, Fl_Darwin_System_Driver and Fl_WinAPI_System_Driver.)ALL of these should have been called "clocale_vsscanf" (with a "V") instead, since they take a va_list item, rather than a varags list "..."I note that there is also a wrapper in Fl_preferences that is correctly called clocale_sscanf() that does take a "..." vararg so it is OK - these others are all misnamed here.Should we correct the naming now?
I do not know, but AFAICT the only place they are used is from Fl_Preferences, so the "damage" from renaming them would be very limited.I doubt anyone has used these methods directly in user code!
By the same token, in our driver layer (for each platform) we also have clocale_printf that should be clocale_vprintf and clocale_snprintf that should be clocale_vsnprintfsince both take a va_list rather than "..." as the parameter...
Yes, please. It would be a great help if you could do this (since you dived into the code already). TIA
This (renaming) and the replacement of the wrong code above would be very much appreciated.
On Tue, 22 Mar 2022, 16:53 Albrecht Schlosser wrote:
Yes, please. It would be a great help if you could do this (since you dived into the code already). TIA
This (renaming) and the replacement of the wrong code above would be very much appreciated.
OK, I'll have a look, though won't be this evening (currently watching a kids water polo match, now they're allowed to play competitive matches again...)
The preferred approach is to make a clone on GitHub, do the patch, then send (you?) a PR, I think?Is that the way?
Well, you have write access, so you could commit and push to GitHub (fltk/fltk) yourself.
However, if you prefer to make a PR so someone can review it, then this is how it works: