[問題] Recommended C coding standards 6ed(已補上)

作者: zzss2003 (brotherD)   2018-01-08 14:38:21
圖片:https://imgur.com/a/kopJm
嗨,各位好。小弟最近在唸網路上的Recommended C Style and Coding Standards,想說
可以提高程式的可攜性、簡易debug難度等等。唸到一些覺得跟自己觀念上有矛盾的內容,
想請教各位的看法。
首先先描述這個file的用途、作者、版本等等,這個沒問題,第二個是放header file,也
沒問題。
第三點,Any defines and typedefs that apply to the file as a whole are next.這
句我聽不太懂是什麼意思。我自己的作法是把defines跟typdefs都放在同一個header檔,
然後main.c再include起來。那如果我是用這種方式的話,照作者的意思就是要把這個
header檔的順序排在最後一個囉?
第四點畫紅線的部分我看不懂,不曉得有版友可以給個例子嗎?
謝謝各位!
作者: MOONRAKER (㊣牛鶴鰻毛人)   2018-01-08 15:47:00
紅線是你自己畫的?
作者: dannypsnl (秦書)   2018-01-08 16:18:00
應該是接下來放適用於整個文件的defines跟typedefs的意思
作者: Raymond0710 (雷門)   2018-01-08 18:51:00
只有這.c檔用到的define typedef放在所有#include後
作者: LPH66 (-6.2598534e+18f)   2018-01-09 09:28:00
縮網址是 ppt 的話請換一家
作者: MOONRAKER (㊣牛鶴鰻毛人)   2018-01-09 14:58:00
還是看不到紅線啦 什麼都沒看到
作者: phishingphi (hsnutontu)   2018-01-14 01:09:00
目前我看到的紅線文字為 If a set of definesapplies to a particular piece of global data(such as a flags word), the defines should beimmediately after the data declaration orembedded in structure declarations, indented toput the defines one level deeper than the firstkeyword of the declaration to which they apply.不負責的解讀成某個資料結構先宣告出來,那些相關的defines出現的位置,要嘛是在那個 data structure 後不然就是 embedded 在 structure 裡面並且縮排。比如說一個 struct audit_context 用某個 enumaudit_context 表示其狀態,他應該在規定那個 enum出現的次序為何enum 應該出現在那個 struct 之後或者包在 struct 內並且要縮排一層

Links booklink

Contact Us: admin [ a t ] ucptt.com