Understanding Kdevelop Source Code

Lucas Tanure tanure at linux.com
Sat Mar 14 20:44:45 UTC 2015


On Sat, Mar 14, 2015 at 5:37 PM, Alexander Richardson
<arichardson.kde at gmail.com> wrote:
> 2015-03-14 20:04 GMT+00:00 Lucas Tanure <tanure at linux.com>:
>> Hi,
>>
>> I'm studying kdevelop code to in the future help the project. So, I
>> have a small question :
>>
>> kdevplatform/serialization/itemrepository.h:98
>> enum {
>>     ItemRepositoryBucketSize = 1<<16
>> };
>>
>> Why do this way ? What are the benefits?
>>
>> Why not ?
>> #define ItemRepositoryBucketSize 65536
>>
> I can't comment on the 65536 vs 1 << 16, but I would always use an
> enum over a #define for integer constants since both have no runtime
> overhead but #defines could break code such as
>
> int ItemRepositoryBucketSize = 15;

What do you mean by that? why would break ?

>
> While it is unlikely that this would happen with
> ItemRepositoryBucketSize, there might be enumertors where this is a
> real issue. Also once we can use c++11 strongly typed enums it is easy
> to tell whether the value needs to be stored in an int or an int64,
> etc.
>
> Alex


Thanks

--
Lucas Tanure


More information about the KDevelop-devel mailing list