Did import type of C enums change in Swift 5 development snapshot?

a C enum whose cases were previously being imported as Int32 (see SR-3999) has suddenly become of type Int in recent Swift nightlies (5.0-dev (LLVM ab94816b59, Swift f90b782c6e)). As a result some of my projects are no longer compiling, since error codes of type Int32 are being matched against Int enums now. Was this intentional?

this is the C enum in question (custom-imported from freetype)

#define FT_ERRORDEF( e, v, s )  e = v,
#define FT_ERROR_START_LIST     enum {
#define FT_ERROR_END_LIST       FT_ERR_CAT( FT_ERR_PREFIX, Max ), \
    _swiftABIForceSignedInt32 = -1 \
} FT_ErrorCase; 
// named enum with negative case should have turned default 
// `Int` enum  into `Int32` enum

I don't know if this was intentional but I would encourage you to file a bug. I don't think such a breaking change should be intentional that late in the Swift 5 development cycle.

I'm not sure why -1 would result in Int32 instead of Int—it clearly fits in both—but I definitely would not expect that to have changed in the last few weeks. I think we'll need a full preprocessed enum (with values) to know what's going on.

1 Like
Terms of Service

Privacy Policy

Cookie Policy