I think I have a great solution for our limited callback functionality that is compatible with C++98,
but how can I test that? It uses some extensive and unreadable macros and requires __VA_ARGS__, which was only "standardised" in C++99, but most older compiler "just had it".
Anyway, the solution is a header-only file that generates more complex callbacks on the fly, so simply not including the header would keep full compatibility.
My question is, is there any way to test if my code would compile on old compilers?
Or should I just merge it, and we will wait for feedback?
On 5/8/23 03:14, imacarthur wrote:
On Saturday, 6 May 2023 at 10:44:17 UTC+1 Matt wrote:
My question is, is there any way to test if my code would compile on old compilers? Or should I just merge it, and we will wait for feedback?
How far back do we want to go?Greg maybe still has MSVC-6 for example?
Ok, so I used https://godbolt.org (awesome!) to compile with any meaningful compiler down to Spark, Webassembly, ESP32, and llvm for Commodore C46. Lowest gcc available is 4.8.5.
MSVC does not go low at all. The code does compile a test macro on each and every one of them. Only if I set `-std=c++98` and pedantic, I will get an error: anonymous variadic macros were introduced in C99.
Not sure if that is acceptable.
I can of course rewrite this to use a trailing number for number of arguments... : `FL_FUNCTION_CALLBACK_3(btn, something, int, a, 3, int, b, 4, int, c, 5)`
Albrecht Schlosser schrieb am Dienstag, 9. Mai 2023 um 21:33:16 UTC+2:
On 5/8/23 15:58 'melcher...' via fltk.coredev wrote:
I can of course rewrite this to use a trailing number for number of arguments... : `FL_FUNCTION_CALLBACK_3(btn, something, int, a, 3, int, b, 4, int, c, 5)`This would be an interesting change because it would make sure that you assign the correct number of arguments (triplets) for every macro. Should be considered, IMHO. Even better if it also increases compatibility...
Unfortunately we can't have it both. The compiler throws an error es soon as it sees the ellipsis (...). But I could disable the varargs version if fl_attr.h determines a really old compiler.
On Wednesday, 10 May 2023 at 09:06:57 UTC+1 Matt wrote:
Albrecht Schlosser schrieb am Dienstag, 9. Mai 2023 um 21:33:16 UTC+2:
On 5/8/23 15:58 'melcher...' via fltk.coredev wrote:
I can of course rewrite this to use a trailing number for number of arguments... : `FL_FUNCTION_CALLBACK_3(btn, something, int, a, 3, int, b, 4, int, c, 5)`This would be an interesting change because it would make sure that you assign the correct number of arguments (triplets) for every macro. Should be considered, IMHO. Even better if it also increases compatibility...
Unfortunately we can't have it both. The compiler throws an error es soon as it sees the ellipsis (...).
But I could disable the varargs version if fl_attr.h determines a really old compiler.
FWIW, I'm inclined towards the variadic macro solution.
Maybe, as Albrecht suggested earlier, we can include something in the docs. to the effect of "If you are using an older compiler that does not support variadic macros, this feature will not be available, so in that case do not use it!"
I'd assume anyone choosing to use an old compiler toolchain is doing so for a reason, probably knows what they are doing, and may well be running on ancient hardware that has limited capabilities anyway...