bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

enum vs int and API/ABI compatibility


From: Simon Josefsson
Subject: enum vs int and API/ABI compatibility
Date: Wed, 19 Oct 2011 13:06:38 +0200
User-agent: Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.90 (gnu/linux)

This is not related to gnulib strictly, but I'd like to consult the
wisdom on this list.  I'm considering changing the argument to some
functions in GNU Libidn from 'enum' to 'int' to silence C++ warnings
(see [1] for discussion).  The change I'm considering is from:

  typedef enum
  {
...
  } Idna_rc;
...
  extern IDNAPI const char *idna_strerror (Idna_rc rc);

into

  extern IDNAPI const char *idna_strerror (int rc);

Some things that I wonder:

1) Is there any platform where this has any implications for the ABI?

1b) Any reasonable platform?

2) Are there any other negative risks with the API change?  In C, enum
and int should be interchangeable, and gcc does not seem to warn against
mixing these types.  Other compilers?  I'm willing to live with new
warning messages (which seems unavoidable) but not hard errors.

2b) For C++?  C++ compilers may warn on code that mixes int and enum,
but the current approach (with functions returning int's that really are
enum's) also leads to C++ warnings, so on balance I think the proposed
change is reasonable as it allows future C++ code to be warning free.

Thanks,
/Simon

[1] http://thread.gmane.org/gmane.comp.gnu.libidn.general/355



reply via email to

[Prev in Thread] Current Thread [Next in Thread]