Understanding Kdevelop Source Code
Kevin Funk
kfunk at kde.org
Sat Mar 14 20:41:42 UTC 2015
On Saturday 14 March 2015 17:04:15 Lucas Tanure wrote:
> 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
With regards to: 1<<16 vs. 65536
This is mostly a matter of style, compiler optimizes that out anyway. (Makes it easier to
grasp the author wanted to have a value of power of 2 here.)
You can find lots of resources on the Internet on the "enum vs. #define"
debate.
One of them, with an acceptable answer and follow-ups is here:
http://stackoverflow.com/questions/136946/difference-between-enum-and-define-statements
Short: Don't use #define for defining constants in C++
Situation's a bit different in C, because of:
http://stackoverflow.com/questions/3431895/c-enum-vs-define-for-mathematical-constants
Cheers
> Thanks
>
> --
> Lucas Tanure
> _______________________________________________
> KDevelop-devel mailing list
> KDevelop-devel at kde.org
> https://mail.kde.org/mailman/listinfo/kdevelop-devel
--
Kevin Funk | kfunk at kde.org | http://kfunk.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20150314/457e733f/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20150314/457e733f/attachment-0001.sig>
More information about the KDevelop-devel
mailing list