A type definition can be placed in the header as well in the source file, depending on the scope of the definition. They have to be placed under the TYPEDEFS AND STRUCTURES section. A type definition defined in this section has to meet a number of rules. The name of the typedef starts with a capital and should end with ‘Type’. Furthermore the name has to be capitalized (each word starts with a capital, e.g. ConfigType) to improve readability. The use of underscores is not recommended.
There is however one exception to these rules. The basic types of char, int, short, long, float and double should not be used, but instead newly defined equivalents should be used that define specific storage lengths (According to the MISRA rule 13; see also www.misra.org.uk). This in order to avoid the problem that storage lengths of the basic types vary from compiler to compiler. It is simply safer to work with predefined storage lengths. It makes your code more independent from a compiler and/or processor platform. These new typedefs should preferably be put into a standard header which could be named e.g. stddefs.h, cextdefs.h or common.h. Choose one header file name for your style and use it in all projects and/or throughout your company.
คำนิยามประเภทสามารถอยู่ในส่วนหัวเช่นกันในแฟ้มแหล่งที่มาขึ้นอยู่กับขอบเขตของคำนิยาม พวกเขาจะต้องอยู่ภายใต้การ typedefs และส่วนโครงสร้าง คำนิยามของประเภทที่กำหนดไว้ในส่วนนี้มีเพื่อตอบสนองจำนวนของกฎ ชื่อของ typedef เริ่มมีเงินทุนและควรจะจบลงด้วย 'พิมพ์'นอกจากชื่อจะต้องมีการจัดหาเงินทุน (แต่ละคำเริ่มต้นด้วยเงินทุนเช่น configtype) เพื่อปรับปรุงการอ่าน ใช้ขีดไม่แนะนำ
มี แต่ข้อยกเว้นกฎเหล่านี้ ประเภทพื้นฐานของ char, int, สั้น, ยาว, float และดับเบิลไม่ควรใช้,แต่แทนที่จะเทียบเท่ากำหนดขึ้นใหม่ควรจะใช้ที่กำหนดความยาวการเก็บรักษาที่เฉพาะเจาะจง (ตามกฎ Misra 13; เห็น www.misra.org.uk) นี้เพื่อหลีกเลี่ยงปัญหาที่ความยาวของการจัดเก็บข้อมูลประเภทพื้นฐานแตกต่างจากคอมไพเลอร์เพื่อรวบรวม มันเป็นเพียงความปลอดภัยในการทำงานที่มีความยาวการจัดเก็บข้อมูลที่กำหนดไว้ล่วงหน้า มันทำให้รหัสของคุณมากขึ้นเป็นอิสระจากคอมไพเลอร์และ / หรือแพลตฟอร์มประมวลผลเหล่านี้ typedefs ใหม่ควรจะใส่ลงไปในส่วนหัวของมาตรฐานซึ่งอาจจะมีชื่อเช่น stddefs.h, cextdefs.h หรือ common.h เลือกหนึ่งชื่อไฟล์ส่วนหัวสำหรับสไตล์ของคุณและใช้ในทุกโครงการและ / หรือทั่วทั้ง บริษัท ของคุณ
การแปล กรุณารอสักครู่..
