 public func bitfieldValueCode(_ bf: GIR.Bitfield, _ indentation: String) -> (GIR.Bitfield.Member) -> String {
     let type = bf.escapedName.swift
     return { (m: GIR.Enumeration.Member) -> String in
-        swiftCode(m, indentation + "public static let \(m.name.camelCase.swiftQuoted) = \(type)(\(m.value)) /* \(m.typeRef.type.ctype) */", indentation: indentation)
-    }
-}
-
-
-/// Deprecated Swift code representation of a bit field value
-public func bitfieldDeprecated(_ bf: GIR.Bitfield, _ indentation: String) -> (GIR.Bitfield.Member) -> String {
-    let type = bf.escapedName.swift
-    return { (m: GIR.Enumeration.Member) -> String in
-        swiftCode(m, indentation + "@available(*, deprecated) public static let \(m.name.swiftName) = \(type)(\(m.value)) /* \(m.typeRef.type.ctype) */", indentation: indentation)
-    }
-}
+        let value = String(m.value)
+        let cID: String
+        if let id = m.typeRef.identifier, !id.isEmpty {
+            cID = id
+        } else {
+            cID = value
+        }
+        let comment = cID == value ? "" : (" // " + cID)
+        let cast = type + "(" + value + ")"
+        let code = swiftCode(m, indentation + "public static let " + m.name.camelCase.swiftQuoted + " = " + cast + comment, indentation: indentation)
+        return code
+    }
+}
+
+
+///// Deprecated Swift code representation of a bit field value
+//public func bitfieldDeprecated(_ bf: GIR.Bitfield, _ indentation: String) -> (GIR.Bitfield.Member) -> String {
+//    let type = bf.escapedName.swift
+//    return { (m: GIR.Enumeration.Member) -> String in
+//        swiftCode(m, indentation + "@available(*, deprecated) public static let \(m.name.swiftName) = \(type)(\(m.value)) /* \(m.typeRef.type.ctype) */", indentation: indentation)
+//    }
+//}
 
 
 /// Swift protocol representation of a record/class as a wrapper of a pointer

    let ext = isErrorType ? ": \(GIR.errorProtocol.name)" : ""
    let pub = isErrorType ? "" : "public "
    let vcf = valueCode(indentation)
    let vdf = valueDeprecated(indentation, typeName: name)
    let values = e.members
    let names = Set(values.map(\.name.camelCase.swiftQuoted))
    let deprecated = values.lazy.filter { !names.contains($0.name.swiftName) }

            self.init(rawValue: castTo\(name)Int(raw))
        }
    """ + "\n"
    let fields = values.map(vcf).joined(separator: "\n") // + "\n" + deprecated.map(vdf).joined(separator: "\n")
    let tail = "\n}\n\n"
    let code = alias + head + initialiser + fields + tail
    return code
