From: Hans-Bernhard B. <HBB...@t-...> - 2025-07-01 16:45:55
|
Am 01.07.2025 um 08:31 schrieb Ethan A Merritt: > The basic issue is that different code is needed if color is represented by > a signed integer (e.g. "plot foo lt 2") or by an unsigned 32-bit ARGB value > (e.g. "splot foo with pm3d fillstyle transparent solid 0.25"). I should, in theory, be about equally easy to shift the values of the enum up into the unsigned range, by way of an offset. But that will of course lead to some level of confusion between the numeric value presented to the user, and the actual numbers seen in, e.g., a debug session. OTOH, looking at that union in a debugger might be equally confusing. Mileage will vary. That said, I'm kind-a surprised that this only shows up now. Surely gnuplot has been running on countless ARM Macs, Raspberry PIs and similar things for ages. And yet this was never seen before? To me that feels like a hint that the actual problem may be not what we currently think it is. > However IMO a cleaner approach is to modify the t_colorspec structure > using an anonymous union to distinguish between the two cases: I'm not quite convinced that an _anonymous_ union is really better than a named one, for this purpose, but the difference is small enough to be ignored. > So the question is, is it worth adding a requirement for C compiler that supports > C11 or at least supports anonymous unions? Setting aside whether anonymous unions are sufficient reason to do it right now, the switch itself is probably a good idea anyway. |