[Bf-committers] int vs enum use?

Brecht Van Lommel brechtvanlommel at pandora.be
Mon Jul 8 00:53:03 CEST 2013

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:

On Sun, Jul 7, 2013 at 8:54 PM, David Jeske <davidj at 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 at blender.org
> http://lists.blender.org/mailman/listinfo/bf-committers

More information about the Bf-committers mailing list