** Software Company Software Development Norm (Trial Edition) In the case of company team collaboration, an important aspect of programming should emphasize is an easy-to-readability of the program, and in the case of ensuring performance indicators to meet user needs. , Let other programmers easily read your program. A set of distinctive programming styles allows collaborators, successors and themselves at a glance, seeing the structure of the program, understanding the idea of design in a short period of time. Great to improve code readability, reusability, program robustness, portability, and maintenanceability. The purpose of this programming specification is to improve the company's software development efficiency and the maintenanceability of the software developed, and improve software quality. This specification consists of the program style, naming rules, annotation specification, program robustness, portability, error handling, and software modular specification. I. Program style: 1. Strictly use the ladder hierarchical program code: The indented points of each hierarchy use VC's default style, that is, each hierarchy is 4 grids, and parentheses are located in the next line. The parentheses required to match in the same column, and the contingent is required to renew 4. For example: void main () {... long li; // loop variable long lsum; // is used to record and float Favg; // is used to seek average value ... // logarithm Accumulated. For (Li = 0; Li <10; Li ) {lsum = lsum li; ...} // seeks average. Favg = lsum / 10.0; ...} 2, prompting the location of the information in the program to be given prompt string, in order to support the development of multiple languages, in addition to some temporary information given to the debug, All other prompts must be defined in the resource. 3, the definition of the variable is as possible to the beginning of the function. Second, naming rules: 1. Naming rules of the variable name 1, the naming rules of the variable require the "Hungarian rules". That is, the 开 字 字 变 变 英 部分 写 写 写.. 字.............................. That is: the variable name = variable type variable English meaning (or abbreviation) to non-universal variables, add an comment instructions when defined, and the variable definition is as possible to place the function. See below: Bool (Bool) Bisparent Byte (BYTE) with the beginning of the BYFLAG SHORT (INT) with N starting NSTEPCOUNT long (long) with the beginning lsum char (char) with c head ccount float (float) F Head Favg Double (Double) with D Ddeta Void (Void) with V starts vvariant unsigned short (word) W-head WCOUNT UNSIGNED Long (dword) with DW start DWBROAD HANDLE (Hinstance) with H Head HHANDLE DWORD with DW DWORD LPCSTR (LPCTSTR) Use the STR start strstring with 0 ends of the string with the SZ start SZFileName proposes and gives a naming recommendation to the technical committee.
2, the basic principle of pointer variable name is: the basic principle of a heavy pointer variable is: "P" variable type prefix naming, such as a float * type should be represented as the basic rules for PFSTAT to multiple pointer variables as: two pointers: "PP" variable type prefix named triple pointer: "PPP" variable type prefix name ... 3, global variables start with G_, such as a global long variable is defined as g_lfailcount, ie: variable = G_ variable type variable English meaning (or abbreviation) 4, static variable starts with S_, such as a static pointer variable is defined as s_plperv_inst, ie: variable name = S_ variable type variable English meaning (or Abbreviations) 5, the member variable starts with M_, such as a long member variable is defined as m_lcount; ie: variable name = m_ variable type variable English meaning (or abbreviation) 6, for enumeration type (enum) Variables require prefix with enumeration variables or their abbreviations. And require capitalization. Such as: enum cmemday; emdays_tuesday; ......}; 7, naming requirements for Struct, Union, Class variables. And to add a prefix, the naming rules of its internal variables are consistent with variable naming rules. Structure generally uses Steres such as: Struct SCMnPoint {INT NX; // point x position int NY; // point Y position}; the consorted body is generally used as the beginning such as: union ucmlpoint {long lx; long l;} class Express with C, such as: float fpoint;}; for general structures should be defined as class templates, for future scalability, as: Template
For example, a function of an image editing that is taken from the dynamic library is defined as imgfunctionName (where IMG is image abbreviation). Now give the naming prefix of the three libraries: 1, the general-purpose library, using cm prefix. 2, for the three-dimensional function library, using VR-based prefix. 3, to the image function library, use IMG as a prefix. For macro definition, the results code use the same prefix. 5. Naming specification (including dynamic libraries, components, controls, engineering files, etc.): The name requirement of the file name expresses the content of the file, requiring the length of the file name to be less than 5 letters, strictly forbidden to use the like File1, Myfile File names. Third, Note Specification: 1, the comment of the function head For functions, you should use the following format from "Function", "Parameters", Return Value, "Main Ideas", "Call Method", "Date" six aspects: // Program Description Start / / ============================================= ===================== // // function: Remove another String from a string. // Parameters: strBydelete, Strtodelete // (inlet) strBydelete: Deleted strings (original strings) // (export) Strtodelete: String to be removed from the previous string. // Return: Find and delete it to return 1, otherwise return 0. (To list an error code) for the return value with error code. // Main ideas: This algorithm mainly uses a cycle comparison method to find // with StrByDelete, which matches STRTODELETE, has multiple StrByDelete substrings in multi-match StrByDelete substrings.
See: // Name ... // Call Method: ... // Date: Start Date, such as: 2000/8 / 21.9: 40--2000 / 8 / 23.21: 45 / / =========================================================================================================================================================================================== ================= // Function name (...) // Site, for some functions, the partial parameters are incoming values, and some parameters are outgoing Value, so the parameter should be described in detail. This parameter is an entry parameter or an export parameter. For some meaningless parameters, it is necessary to do a detailed description (for example, when an angle is used as a parameter, the angle parameter is in an arc (Pi) ), Or units), the variables that are both inlet and exports should be indicated at the same time at the entrance and exit. and many more. 2, the comment of the function should be placed in the header file of the function, and the implementation portion of the function in the implementation file should be placed at the same time. 3, in the comment, the main implementation of the function should be described in detail, especially to indicate some of your thoughts, if necessary, should be written by the idea. For some mimic functions, you should comment on the source of the function. 4, in detail in detail, indicate the appropriate call method of the function, and the processing method of the return value, etc. Where you want to emphasize the danger of call during the comment, you may be wrong. 5. Note on the date requires the date between the test from the start write function to the end function. 6. The function comment begins to the function name between the function name should have a special string used to identify. If the algorithm is complicated, or the variable definition in the algorithm is related to the location, the definition of the variable is required to illustrate. Algorithms that are difficult to understand can illustrate as much as possible. 2. Note: The annotation of the variable is followed by the function of the variable after the variable. In principle, for each variable, it should be annotated, but there are very significant variables, such as: I, J and other cyclic variables may not comment. For example: the root of Long LlineCount //. 3, Note: Document should add the following notes in the beginning: // Project: The item name where the file is located. // Author: **, modified by: ** // Description: Feature Description file. // Main functions: ............ // Version: Description file version, complete date. // Modify: Describe the modification of the file, modify the reason, and the date of modification. // Reference: ... / For the header file to be repeatedly included as the header file is defined as follows: #1fndef __filename_h__ #define __filename_h__ where the filename is the name of the header file. 4. Other Note: We don't need to comment every line of statement in the function. However, you must add block annotations before each of the function modules, annotate each group of statements, each branch of the loop, process, etc., as much as possible. The cycle, condition, and selective position must be annotated. For the case where the order of the front and rear, it is recommended to add the serial number in the comment.
For example: ... // 1, ...... Note for (...) {} if (...) {// ... Comment} Else {// ... Note} // ... Comment Switch (...) {Case: ... // ...... note .. .... Case: ... // ...... Note ... Default: // ... Note ...} Performed in other order In the program, every 3-5 line statement must be added, and a note must be added to the function of the small module composed of this statement. For some of the unique ideas requirements, it is launched in the comment. Fourth, program robustness: 1. Return value specification for functions: For the return position of the function, try to keep a single system, that is, a function is trying to do only one return position. (Single-in-one exit). Ask everyone the return value of the unified function, and all the return values of all functions will return in a coded manner. For example, the code is defined as follows: #define cm_point_is_null cmmakehr (0x200):: The suggested function implements the following: long function name (parameter, ...) {long LRESULT; / / Keep error number LRESULT = cm_ok; // If the parameter has an error, return an error IF (parameter == null) {LRESULT = cm_point_is_null; goto end;} ... end: return LRESULT;} 2, About GOTO Application: Application to goto statement, we require minimize GOTO statements. The required place for a certain amount of place can only be transferred backwards. 3. Processing of resource variables (resource variable refers to the variable of consumption system resources): The initial value must be assigned to the resource variable. The allocated resource must be released immediately after the use, and re-assaptuous values. Example: long * flatocmem; // Defines a variable allocated in memory. PLALLOCMEM = (long *) Calloc (40, sizeof (long)); // Assign a memory. // Process allocation memory error if (planocmem == null) {LRESULT = cm_mem_alloc_failed; goto end;} ... use memory ... // Release resource variables and re-assapt. IF (PallocMem! = NULL) {free (PLALLOCMEM); PallocMem = NULL;} 4, judging complicated conditions, for program readability, should be used to use parentheses. Example: IF ((SZFileName! = Null) && (LCOUNT> = 0))) || (Bisreaded == True)) 5. Portability: 1. High quality code requirements can be cross-platform, so our code Support for different platforms should be considered, especially for Windows98 and WindowsNT. 2. Since the C language is better, the C code is required for the algorithm function, and C code cannot be used. 3. Do different processing for different hardware and software functions. V. Error handling: 1. Error report processing. The various executions of the function are required to consider the functions of the function, and all process conditions can be handled as much as possible. The function is divided into two categories: a class is not related to the display of the screen, (not with the user exchange information), is related to the display of the screen. (Function with the user exchange information) Reports an error by the return value for functions independent of the screen display. For functions related to the screen display, the function is responsible for issuing a warning to the user and performs an error handling. Error handling code is typically separately established a universal processing function.
As follows: void cmdeal_with_ERROR (long errcode) {copy 1: // Note ... case 2: // Note ... default: // Comment ...} } 2, find out the error in the program as soon as possible: 1, pay attention to the warning information in the compiler. For warning messages generated by the compiler, we should attach enough attention, in fact, many warning information indicate potential errors in the program. So we must carefully check each warning message to see if there is a hidden danger. Try to eliminate warning information. 2, using assertions to check the error for some assumption in the program, or prevent the illegal value of certain parameters, using assertions to help find the error is a good way. For example, the following functions: long cmmemcpy (void * pvfrommiem, size_t wsize) {... if (pvtomememmmmem == null || pvfrommem == null) {LRESULT = cm _point_is_null; goto: end;} while (wsize -> 0) {* PVTOMEM = PVFromMEM ;} end: return LRESULT;} Adoption of the incoming pointer error, but this judgment is that the final compiletable code becomes large, while reducing the performance efficiency of the final release program . Since the incoming empty pointer is obviously the error of the program that calls this function, instead of this function error, we can consider using the assertion instead of the pointer check, that is, use Assert (pvtom! = Null && pvfrommem! = Null) instead of IF (PVTOMEM == Null || pvfrommem == null) {LRESULT = CM_POINT_IS_NULT = CM_POINT_IS_NULL; GOTO: END;} This will only produce check code in the debug version, and these code will not be included in the formal release. And it can be convenient for us to find errors during program debugging and testing, while do not affect the efficiency of the program. In some cases below, you must have a step: a, number of parameters, especially the pointer parameters must be confirmed by assertion. b, using the correctness of various assumptions in the assertion check program. c. Don't easily think that something impossible in the programming is not possible. If you think it is impossible, it must be confirmed by an assertion. In order to make the assertion in the program functions, all dynamic libraries for testing or debugging inside the development must adopt a debug version. Explanation: In the program efficiency requirements, or call more frequent functions, the error checking for the entrance parameters, the advantages are as described above, but their robustness is not strong, so in other cases, the use of traditions The inspection method is to enhance the robustness of the program, of course, for the convenience of debugging, can simultaneously use the assertion mode. 3, strict test: Strict tests are required for each code, especially for some functional functions to test their various critical points (such as zero value, infinity values, etc.). Try to do a zero error in each section. Sixth, modular specification: in order to improve software reuse, reduce the workload of repeated development. At the same time, in order to improve the readability of the program, it is easy to maintain the maintenance of the program, and the modular work of the software must be strengthened. Modularity should follow the following basic specifications: 1, a function should be flexible, the code of the function should be controlled in a moderate scale, each function code is generally not more than 150 lines, if exceeding this size, should be performed Modular work.
For some special functions, it is indeed more than 150 lines, and it should be submitted. After passing, the writer is required to more detailed a more detailed payment, and the cause of the function is superficial, as well as design ideas. 2, a function, if you repeatedly implement more than three times, you should consider modular, write it into a general function. And released to the developer. And request the interface documentation and implementation function file. 3. Each developer uses the ready-made module from others as much as possible to reduce duplication development. 4. When performing a function of function, consider the hierarchical relationship of the function, especially when adding a new functional module, the original function code should be carefully adjusted, and the different functions of the same function are not repeated, this requirement The purpose is to facilitate code maintenance. Examples are as follows: The following functions: // Repair from the SZFileName file ... long ... c_szfilename, ...) {cfile * pfile; // To save the address of the file pfile = new cfile (c_szfilename, cfile :: modeRead); // Create a read-only file if (pfile == null) {LRESULT = cm_point_is_null; goto end;} // read from the file ...... ... // Close the file delete pfile; end: return LRESULT;} If you need to increase the new function as the following interface now: long ... cmreadsomething (cfile * pfile) {ix (pfile == null) {LRESULT = cm_point_is_null; goto end;} // Read from the file ... ... end: return LRESULT;} requires the following: Will .... ..cmgetsomething (const char * c_szfilename, ...) is changed to long ... cmgetsomething (const char * c_szfilename, ...) {cfile * pfile; // Used to save open Document address long LRESULT = cm_ok; // Error return code // Open file Pfile = new cfile (c_szfilename, cfile :: modeRead); if (pfile == null) {LRESULT = cm_point_is_null; goto end;} // Read ... LRESULT = cmreadsomething (pfile, ...); if_error_goto_end // Close the file delete pfile; end: returnizult;} Modules some precautions: 1, design module interface See the object-oriented view, including: function interface and variable interface. 2, do not change easily after the interface is defined, and explain it in the beginning of the module (the beginning of the file), so when defining the interface, it must be repeatedly pondered and keep the style. 3, pay attention to global variables is also an interface. If it is not necessarily necessary, we should use less global variables. 4, in the function interface, try to make the interface interface easily and use, where each input / output parameter represents a type of data, do not mix the error value and other dedicated values in other input output parameters of the function. 5, strive to write a function that is always successful, so that the caller does not have to perform corresponding error processing.
This specification is a trial version, and the right to interpret belongs to the technical committee of the ** software company! Employees are written when writing programs: functemplate.h // // Project: functemplate.h // // Description: Some algorithms to the binary tree, and matrix memory allocation. // // Version: FuncTemplate version 1.0. // // typedf struct _node // Define a node {structure _node * PleftChild; // node left child struct _node * pRightchild; // node's right child} node; // ========== ============================================================================================================================================================================================================= ====== // // Function: Use a loop to implement the left sequence traversal of the binary tree // // Parameter: pnode // // (inlet) PNODE: the entrance address of the binary tree, the address of the root node. // / / (export) is not. // // Return: Long's function return code, if the return value is cm_ok, the table is successfully traversed, returning // cm_point_is_null table two-fork pointer is empty.
// / / ============================================== ==================== // long cmwalktreeusecycle (const node * pnode); / / ================= ============================================================================================================= / / / /: 参 功能 参 功能 参 参: wrowsize, wcolsize, pplmatrix // // (inlet) WROWSIZE: The number of rows of matrices; // (入) WCOLSIZE: Matrix number; / / / / (Ignition) PPPPLMatrix: The address of the matrix to be assigned; // (export) PPPLmatrix: Assigned matrix address; // Return: long error number, if the return value is cm_ok, the table allocation is successful , Return // // cm_pointer_is_not_null table matrix inlet address value is not empty. // / / CM_MEM_ALLOC_FAILED system insufficient memory // / / ====================================== =========================================================================================================== # .cpp // // project: FuncTemplate.cpp // // author: ** // // modified by: **, *** // // description: the algorithm used to deal with some of the binary tree, and matrix memory distribution. // Main functions: cmwalktreeusecycle, cminitmatrix // version: FuncTemplate version 1.0.
// Completion date: 2000-8-26 // // Modified Date: 2000-8-27, 2001-12-21 // // Reference: Graphics Developer Guide (Machinery Industry Press) // #define Strict #include "stdio.h" #include "stdlib.h" #1 "#" c "{#ndif / * __cplusplus * / #include" MakehResult.h "#include" Memory.h "#include" FuncTemplate.h "#define cm_mem_pointer_is_null cmemakehr (0x100) // Error indicating that the pointer is not empty #define cm_mem_pointer_is_not_null cmemakehr (0x101) / / indicates that the pointer does not empty the error #define max_pushed_nodes 100 // Define the maximum stack quantity program function description start // ============================================================================================================================================================================================================= ================ // function: use loop to realize the left sequence traversal of the binary tree // parameter: cpnode // // (inlet) CPNODE: the entrance address of the binary tree, ie Node's address. // (export) is not. // // Return: LONG function return code, if the return value is cm_ok, the table is successful, and the return // ms_point_n /null table binary pointer is empty. // Call method: Before calling this function, you must initialize the binary tree // think: If you are accessing a node, if the node has left branches, you will first access left branches. / / The node is then accessed if the node also has a right branch. Enter the right branch again. // When accessing left branches, tag is made in the stack, and this is accessed when the left branch is processed. After each node is accessed, if the node does not have the right child, and the stack has been // is empty, then the access to the node is complete, the code is repeated to each node in //.
// // See: Graphics Developer Guide (Machinery Press) Page: 927 / / Date: 2000/8 / 26.9: 40--2000 / 8 / 26.21: 45 / / ======== ============================================================================================================================================================================================================= ======== // diagram: // root node @ @ / @ @ 孩子 // / / / / / / / / / / @ @ @ @ @ // Left child right child left child right child HRESULT CMWALKTREEUSECYCLE (const node * cpnode) Program function Description End {hResult LRESULT; // Used to save the returned error number. Node * pnodestack [max_pushed_nodes]; // is used as a stack of nodes. Node ** PPNODESTACK; / / The pointer used to indicate the node stack. LRESULT = cm_ok; // Judging whether the tree is empty. IF (cpnode! = null) {pnodestack [0] = null; // Setting the stack is empty. PPNODESTACK = PNODESTACK 1; for (; {// If the current node has left children, putting the current point stack. // Move the current point to the left child, start traverse the left sub-tree, //, until the found Left child's node. While (cpnode-> PleftChild! = Null) {* PPNodeStack = (Node *) cpnode; cpnode = cpnode-> Pleftchild;} // We are now in the left child's node, so access // node, If there is a right child, then access the right child. Or // The post-in-node. Duplicate node's outlet until we find / / have the node of the right tree, or all node outlet for (; {// access node) (Call other functions, no implementation) cmvisitnode (cpnode); // If the node has the right child, make the child become the current festival // point and start traversing the bon tree, otherwise the return node // until we find one The node of the right tree, or the // some of the stack points have been accessed. IF (cpnode-> pRightchild! = Null) {cpnode = cpnode-> PRightChild; Break;} // out of the stack, we can Access it and determine whether there is a right child. If ((cpnode = * (- ppnodestack)) == null) {// Stack is empty and the current node does not have the right child, over // spread. LRESULT = CM_OK; goto end;}}}} // If the pointer sets the return value information to MS_POINT_IS_NULL.
LRESULT = cm_pointer_is_null; end: return LRESULT;} program function description start / / ================================== ==================================================================================== // (Entrance) CWROWSIZE: The number of rows of the matrix; // cwcolsize: Matrix number; // PPPLMatrix: The address of the matrix to be assigned; // (export) PPPLMAMATRIX: Assign the address of the matrix; // Return: long The error number, if the return value is cm_ok, the table is allocated, the return // cm_pointer_is_not_null table matrix is not empty. // cm_mem_alloc_failed system's memory // call method: You must first assign the incoming value before calling this function. A reference value is referenced. // such as: long ** pplmatrix; 即: // pplmatrix = null; call is: cminitmatrix (10, 10, & pplmatrix); // Idea: All rows of memory is allocated, and then each The columns corresponding to the row allocates memory. // See: No // Modify: / / Date: 2000/8 / 29.16: 40--2000 / 8 / 29.16: 45 / / =================== ========================================================= HRESULT CMINITMATRIX (const size_t cwrowsize, const size_t cwcolsize, long *** ppplmatrix) Program function description ends {hResult LRESULT; // Stores the return value. LRESULT = CM_OK; Word Wi; // Requires NULL for the incoming value. if (** ppplmatrix! = null) {LRESULT = CM_POINTER_IS_NOT_NULL; goto end;} // Allocate memory of matrix * * ppplmatrix = (long *) malloc (cwrowsize * sizeof (long *)); // returns if the assignment fails.
IF ((** ppplmatrix) == null) {LRESULT = cm_mem_alloc_failed; goto end;} // allocate memory. For (wi = 0; wi free (** ppplMatrix); ** ppplMatrix = NULL;} return lResult;} #ifdef __cplusplus} #endif / * __cplusplus * / Extended error handling: makehresult.h // // OF: // ** Description: Used Unified regulations for return code // Main function: // Reference: COM technology insider (Microsoft component object model); [US] Dale Rogerson // #ifndef __ERRORDEFINE_H__ #DEfine __ERRORDEFINE_H__ #include "Winerror.h" // Graphic // 3 3 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 // 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 // - ----------------------------- ---- ------------------- // | SEV | C | R | Equipment Code | Class Code | Return Code | // - - ----------------------------------------------------------- ---------- -------- // / / ==================================== ========================== to define the device code // Define the device code defined by the general function #define facility_cm 0x80 // Virtual reality function Defined device code #define facility_vr 0x81 // Device code defined by the image function #define facility_img 0x82 / / ========================== ============================================================================================================================================================================================================= ======= // Define class encoding (the first 6 bits in the post-16 bits) // from 0x00 ~ 0x3f ////, 0x38 ~ 0x3f, to the programmer reserved temporary class encoding. // encoding standard class from 0X00 ~ 0X37 #define MEMORY_CLASS 0x01 #define FILE_CLASS 0x02 / * #define TEMP_CLASS1 0X38 #define TEMP_CLASS2 0X39 #define TEMP_CLASS3 0X3A #define TEMP_CLASS4 0X3B #define TEMP_CLASS5 0X3C #define TEMP_CLASS6 0X3D #define TEMP_CLASS7 0X3E #define TEMP_CLASS8 0x3f * / / / =============================================== ========================== // Make the first three shields of the temporary resource time bits (ie 8 temporary classes), temporary resources From 0x0000 ~ 0x1FFF (programmer input value) // actually 0xE000 ~ 0xFFFF (macro converted) #define addTempClass ((0x38 <10) | LRESULT) // Return to the general function return code type // lResult incoming values between 0X0000 ~ 0X1FFF #ifndef CMEMAKEHR #define CMSMAKEHR (lResult) MAKE_HRESULT (SEVERITY_SUCCESS, FACILITY_CM, ADDTEMPCLASS (lResult)) #define CMEMAKEHR (lResult) MAKE_HRESULT (SEVERITY_ERROR, FACILITY_CM, ADDTEMPCLASS (lResult)) #endif // CMEMAKEHR // define the function returns the return code of the virtual reality type // value passed to the lResult #ifndef VREMAKEHR #define VRSMAKEHR (lResult) MAKE_HRESULT (SEVERITY_SUCCESS, FACILITY_VR, ADDTEMPCLASS (lResult)) #define between 0X0000 ~ 0X1FFF Vremakehr (LRESULT) MAKE_HRESULT (Severity_ERROR, FACILITY_VR, ADDTEMPCLASS (LRESULT)) #EN dif // VREMAKEHR // define the function returns a return code image type // lResult incoming values is between 0X0000 ~ 0X1FFF #ifndef IMGEMAKEHR #define IMGSMAKEHR (lResult) MAKE_HRESULT (SEVERITY_SUCCESS, FACILITY_IMG, ADDTEMPCLASS (lResult)) # define IMGEMAKEHR (lResult) MAKE_HRESULT (SEVERITY_ERROR, FACILITY_IMG, ADDTEMPCLASS (lResult)) #endif // IMGEMAKEHR // occurs when the return code, the // END to return a number with claim lResult, marked with No. END #define IF_ERROR_GOTO_END if Failed (LRESULT) GOTO END; // Display the description of the return code #define display_hresult_Message if (LRESULT)) cmdispResultMessage (LRESULT); typedef long hResult; typef long lresult; / / ================= ============================================================================================================================================================================================================= // maintain and windows systems (com) consistent #define CM_OK S_OK #define CM_FALSE E_FAIL #define VR_OK S_OK #define VR_FALSE E_FAIL #define IMG_OK S_OK #define IMG_FALSE E_FAIL #define CM_UNKNOW_ERROR CMEMAKEHR (0X000) // // unknown error memory error #define CM_MEM_ALLOC_FAIL CMEMAKEHR (0X001) // memory allocation failure #define CM_MEM_FREE_FAIL CMEMAKEHR (0X002) // memory release failure #define CM_INVALID_POINTER CMEMAKEHR (0X003) // // invalid pointer file * want * to make #define CM_CREATE_FILE_FAIL CMEMAKEHR (0X010) // file creation failed #define CM_OPEN_FILE_FAIL CMEMAKEHR (0X011) // file open failed #define CM_CLOSE_FILE_FAIL CMEMAKEHR (0X012) // file close failed #define CM_DELETE_FILE_FAIL CMEMAKEHR (0X013) // file removal failed #define CM_FILE_HAS_EXISTED CMEMAKEHR (0X014) // file already exists #define CM_COPY_FILE_FAIL CMEMAKEHR (0X015) // file copy failed #define CM_FILE_NOT_OPEN CMEMAKEHR (0X016) // file does not open #define CM_READ_FILE_FAIL CMEMAKEHR (0X017) // file read failed #define CM_FIND_FILE_FAIL CMEMAKEHR (0X018) // file Find failed #define cm_file_has_error cmemakehr (0x019) // File itself is wrong #define cm_write_file_fail cmemakehr (0x020) // file write failed // array * want * Do #define cm_Array_beyond cmemakehr (0x060 ) // // functions array bounds * want * to make #define CM_PARAM_BEYOND CMEMAKEHR (0X030) // // database parameter out of range * want * to make #define CM_OPEN_DATABASE_FAIL CMEMAKEHR (0X040) // open the database failed #define CM_OPEN_TABLE_FAIL CMEMAKEHR (0X041) / / data table open failed #define CM_TABLE_BEYOND CMEMAKEHR (0X042) // data sheet access violation #define CM_CREATE_DSN_FAIL CMEMAKEHR (0X043) // create a data source failed #define CM_TABLE_EXIST CMEMAKEHR (0X044) // table already exists #define CM_DATABASE_NOT_OPEN CMEMAKEHR (0X045) // Database does not open // Other * Thinking * Do #define cm_beyond_param cmemakehr (0x100) // Parameter Crossing #define cm_point_is_invaliad cmemakehr (0x101) // illegal point // Image * I want * Do #define cm_create_bmp_fail cmemakehr 0x200) // Create a bitmap failed // thread * want * Do #define cm_thread_is_lock cmemakehr (0x300) // thread back lock // mathematical calculation #define cm_edgenum_notenough cmemakehr (0x500) // The number is not enough // network * want * Do #define cm_connect_fail cmemakehr (0x700) // Connection failed // * Want * to make three-dimensional device #define DD_CREATE_DEVICE_FAIL CMEMAKEHR (0x400) // create a device failure #define DD_DELETE_DEVICE_FAIL CMEMAKEHR (0x401) // remove the device failed #endif // __ ERRORDEFINE_H__ #ifndef __ERRORMATCH_H__ #define __ERRORMATCH_H__ #include "errordefine.h" #include "windows.h" //errormatch.h // used to false matches #define lResultCount 128 #define IF_ERROR_DISPLAY_MESSAGE if (FAILED (lResult)) {DisplayChineseMessage (lResult); goto END;} #ifndef SAFE_DELETE #define SAFE_DELETE (p ) {if (p) {delete (p); (p) = null;}} #ENDIF #ifndef Safe_Delete_Array #define Safe_Delete_Array (P) {if (p) {delete [] (p); (p) = null; }} #ENDIF / / ============================================ ============================================ TypedEf struct _Resultinfos // Display return code information {long LRESULTNO; // Returns Code No. CHAR SZRESULTMESSAGECHINESE [40]; // Returns the Chinese Description of Code Char SzResultMeengLish [40]; // Return to the code} ResultInfos; / / ================ ============================================================================================================================================================================================================= ============== sat = {{cm_mem_alloc_fail, "Memory Allocation Fail", "MEMEROY"}, {cm_mem_fr EE_FAIL, "Memory Release Failed", "Memeroy"}, {cm_invalid_pointer, " Invalid pointer "," memeroy "}, {cm_create_file_fail," memory allocation "," memeroy "}, {cm_open_file_fail," file open failed "," memeroy "}, {cm_close_file_fail," file shutdown failed "," memeroy " }, {Cm_file_has_existed, "file already exists", "memeroy"}, {cm_copy_file_fail, "file copy failed", "memeroy"}, {cm_file_not_open, "file is not open", "memeroy"}, {cm_read_file_fail, "file read Take failure "," memeroy "}," file lookup failed "," memeroy "}, {cm_file_has_error," file itself "," memeroy "}, {cm_write_file_fail," file write failed "," memeroy "," Memeroy "," MEMEROY " "}, {Cm_array_beyond," array crosses "," memeroy "}, {cm_param_beyond," Parameter Crossing "," Memeroy "}, {cm_open_database_fail," Database Open Failed "," MeMeroy "}, {cm_open_table_fail," Data Table Open Failure "," memeroy "}, {cm_table_beyond," Data Table Access "," Memeroy "}, {cm_create_dsn_fail," Create Data Source Failure "," Memeroy "}, {cm_table_exist," Table Existing "," Memeroy " }, {Cm_database_not_open, "database is not open", "memeroy"}, {cm_create_bmp_fail, "Create bitmap failed", "memeroy"}, {cm_thread_is_lock, "thread back lock", "memeroy"}, {cm_point_is_invaliad, " Point is illegal point "," "}, {dd_create_device_fail," Create device failed ","}, {dd_delete_device_fail, "delete device failed", "}}; static char * getCHINESEMESSAGE (HRESULT LRESULT) {for (long" Li = 0 ; LI