[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: enum vs int and API/ABI compatibility
From: |
Bruno Haible |
Subject: |
Re: enum vs int and API/ABI compatibility |
Date: |
Thu, 20 Oct 2011 23:47:32 +0200 |
User-agent: |
KMail/1.13.6 (Linux/2.6.37.6-0.5-desktop; KDE/4.6.0; x86_64; ; ) |
Simon Josefsson asked:
> > 2) Change the argument type of idna_strerror to 'int'.
> > Change the enum from
> >
> > typedef enum {
> > ...
> > IDNA_ICONV_ERROR = 9,
> > ...
> > } Idna_rc;
> >
> > to
> >
> > typedef int Idna_rc;
> > #ifdef __cplusplus
> > /* In C++ we avoid macros. */
> > ...
> > const int IDNA_ICONV_ERROR = 9;
> > ...
> > #else
> > ...
> > #define IDNA_ICONV_ERROR 9
> > ...
> > #endif
>
> Why is this second part needed?
It is in fact not needed (cf. ISO C99 section 6.7.2.2.(3)). You can also
write
typedef int Idna_rc;
#ifdef __cplusplus
...
const int IDNA_ICONV_ERROR = 9;
...
#else
enum {
...
IDNA_ICONV_ERROR = 9,
...
};
#endif
Bruno
--
In memoriam Eduard Brücklmeier <http://en.wikipedia.org/wiki/Eduard_Brücklmeier>