python - Enums in C: What assumptions can be made about the value of the underlying variable? -


I am writing some Pyro code which calls a C DLL call through the python ctypes module Does.

In the question, DLL defines some return value in header files in enum s:

  // // Device Status // Enum {FT_OK, FT_INVALID_HANDLE, FT_DEVICE_NOT_FOUND, FT_DEVICE_NOT_OPENED, FT_IO_ERROR, FT_INSUFFICIENT_RESOURCES, FT_INVALID_PARAMETER, & lt; Continuous --- Erosion & gt; };   

I am interfering with Python, so I do not have the original energy. Can I assume that the content of the value starts with the value of 0 , and for each item can be increased by 1? It is very easy to implement, but it seems that I rely on the details of the implementation of the compiler.

I have digged something about the difference of enum , but I did not find much information about how they work internally. C / C # / The only document of how to use them.

I know that if there were constant definitions for different variables in enum , then I could trust it, but in this case, I can interface with the external code. I've got no access to (just DLL).

section in 6.7.2.2 calculation specifier The paragraphs 3 say:

If the first count is not a number, its value of continuous calculation is 0. The calculator after each = no, defines the continuation of its calculator as the value of the expression, which is obtained by adding the value of the previous counting constant to 1. (Using the calculator with values ​​can produce the counting constant with values, which repeat the other values ​​in the same values.) The calculator of an enumeration is also known as its members.

To illustrate the example:

  enum hue {chartreuse, burgundy, claret = 20, winedark};   

And say:

Enumerated values ​​are set in {0, 1, 20, 21}. It is not clear if you are related to the underlying type but the paragraphs 4 says:

Each enumerated type Four will be consistent with a signed integer type, or an unsigned integer type. Type option is implementation-defined, 110), but will be able to represent the values ​​of all members of the calculation. The enumerated type is incomplete until the calculator terminates the list of announcements.

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -