function return value type is enum type

Source: Internet
Author: User
Enumerations are a good thing, and as with structs, you can define a data type, but an enumeration has the advantage that it can specify the initial value of the definition by default. There is a project that involves CPU cards, cards have errors, power up, DF01 directories and other states, if you define these variables separately, to use a lot of variables, here is a rule, that is: The CPU card can not be at the same time several of these states, only one of them, so that we can define an enumeration type variable, For example://Identify several states of the IC
typedef enum
{
Icc_error,
Icc_no_exist,
Icc_exist,
Icc_power_off,
ICC_POWER_ON,
icc_in_dir_1001
} t_iccstatus;     T_iccstatus Geticcstatus; In the program, using this enumeration variable can identify the status of the CPU card in the whole project, concise, clear, and save the use of many global variables.   return value type is enumeration: in general, a function has a return value, in a project, if at each error point, define a return value of a special number, so in main, the return is the unique value, so that the error point can be quickly positioned. If with the above enumeration, the function's return value is defined as the enumeration type, when defining the enumeration, the use of English words to achieve a variety of different return values of the definition, so that in debugging, can well-known express, quickly find the error point, to achieve a multiplier effect.

function return value type is enum type

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.