Re: [Bf-committers] int vs enum use?

2013-07-07 Thread Brecht Van Lommel
One reason is that you can't do forward declarations of enums in
header files like you can do with structs. That means you have to
include header files in header files, which is generally avoided
whenever possible.

I don't think there's a good reason #defines are used instead of enums
to define the actual values, it's mostly out of habit / copying the
style of other files. There is no convention in the code style
guidelines at the moment:
http://wiki.blender.org/index.php/Dev:Doc/CodeStyle

On Sun, Jul 7, 2013 at 8:54 PM, David Jeske dav...@gmail.com wrote:
 Is there any particular reason (besides legacy) that many parts of the code
 still use int/#define, instead of using enums?

 Even though C-compilers don't typecheck enums, there is a documentation /
 readability benefit to using enums. Using enum-forward declaration avoids
 any header nastiness.

 For example ...

 void BKE_nurbList_handles_set(struct ListBase *editnurb, int mode);

 void BKE_nurbList_handles_set(struct ListBase *editnurb, enum
 eHandleSetModes mode);

 The latter is much easier to understand and investigate.

 I'd personally like to make patches which simply add the proper enum types
 to help document things for myself and others. Any reason not to do this?
 ___
 Bf-committers mailing list
 Bf-committers@blender.org
 http://lists.blender.org/mailman/listinfo/bf-committers
___
Bf-committers mailing list
Bf-committers@blender.org
http://lists.blender.org/mailman/listinfo/bf-committers


Re: [Bf-committers] int vs enum use?

2013-07-07 Thread David Jeske
On Sun, Jul 7, 2013 at 3:53 PM, Brecht Van Lommel 
brechtvanlom...@pandora.be wrote:

 One reason is that you can't do forward declarations of enums in
 header files [in ISO C] like you can do with structs.


I see my confusion. gcc has a non-standard extension to support forward
declarations of enums, so it worked fine for me. However, it's not ISO
standard, and as far as I can see MSVC doesn't support it.

http://stackoverflow.com/questions/7480217/c-forward-declaration-of-enums
___
Bf-committers mailing list
Bf-committers@blender.org
http://lists.blender.org/mailman/listinfo/bf-committers