Basic Structure and simple specification of C program

Source: Internet
Author: User

1. process-oriented programming involves several basic elements, which are constrained by programming specifications.

Notes: file comments, function comments, line comments, and block comments.

Compilation preprocessing: File Inclusion, condition inclusion, macro definition, global variable declaration, function declaration, and other compilation preprocessing statements.

Function: The function header, the definition of the function body (flow control statement, data structure and data type (variable or object), operator expression, and function call ).

Error Handling: system call failure, if statement judgment, function entry parameters and exit parameter legality detection, etc.; reasonable error handling structure (Application of macro definition and error information array ).

2. Specifications

I think all naming rules should follow numbers, lowercase letters, and underscores. The Hungary naming and camel naming rules belong to C ++ and java. C should have its own naming rules.

Naming: a variable name and a file name are generally nouns and a verb is used for a function. The macro definition is capitalized. (The above can be underlined ). Avoid magic numbers.

Note: This document describes who completed the file and the copyright version. Function comments should describe the main functions implemented by the function and the parameters to return values, and focus on the global variables called. The line comment block comment is mainly used to explain difficult algorithms.

File structure: the Declaration of global variables is generally placed in a header file. and avoid including multi-file.so using condition-precompile

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.