This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 00/16] Add styling to the gdb CLI and TUI


On 03/21/2019 06:08 PM, Simon Marchi wrote:
> On 2019-03-21 1:02 p.m., Eli Zaretskii wrote:
>>> Cc: tom@tromey.com, gdb-patches@sourceware.org
>>> From: Pedro Alves <palves@redhat.com>
>>> Date: Thu, 21 Mar 2019 16:12:26 +0000
>>>
>>> Is there an advantage of a single variable that encodes the version,
>>> compared to separate major/minor variables?
>>
>> Just that it makes comparison simpler, and IME less error-prone.  Not
>> a very important argument, admittedly.
>>
> 
> Yeah, if you want to check if you are running 8.5 or more, you can do:
> 
> if $_gdb_version >= 805
> 
> With separate components, you have to do something like
> 
> if $_gdb_version_major >= 9 \
>    || ($_gdb_version_major >= 8 && $gdb_version_minor >= 5
> 
> If you need to check for a range, it's even more complicated.
> 
> But then, if the version is provided as separate components, nothing prevents you to re-encode it however you want after that.  You can do easily enough
> 
> set $my_gdb_version = ($_gdb_version_major * 100) + $_gdb_version_minor
> 
> if you want, and use the simple comparison.  And everyone is free to choose their own encoding :).  So, to me separate components sounds better.

Exactly my thoughts.  That's what the GCC manual describes, BTW:

  https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html

Note that with the new gdb version numbering, going forward, for features,
you'll only really care about the major version number, since there won't
be new features added in minor releases.

Thanks,
Pedro Alves


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]