What is the type of an enum whose values appear to be strings?

后端 未结 4 1880
广开言路
广开言路 2020-12-31 07:03

I am working with Apple\'s ScriptingBridge framework, and have generated a header file for iTunes that contains several enums like this:

         


        
4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-31 07:54

    The single quotes indicate characters, rather than strings in C. So each of the enums will have a 32 bit value consisting of the character codes for the four characters. Actual value will depend in character encodings, but I am assuming 8 bit characters. Note there is no appended \0.

    You can use the enums for normal comparison/assignment purposes. As with any enum the underlying type is integer.

    I've used this technique in embedded systems many times to create 4 character 'names' that were human readable in hex dump/debugger contexts.

提交回复
热议问题