C_and_CPP 板


LINE

图片: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档的顺序排在最後一个罗? 第四点画红线的部分我看不懂,不晓得有版友可以给个例子吗? 谢谢各位! --



※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 60.248.26.157
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/C_and_CPP/M.1515393504.A.CE8.html
1F:→ MOONRAKER: 红线是你自己画的? 01/08 15:47
2F:→ dannypsnl: 应该是接下来放适用於整个文件的defines跟typedefs的意 01/08 16:18
3F:→ dannypsnl: 思 01/08 16:18
4F:推 Raymond0710: 只有这.c档用到的define typedef放在所有#include後 01/08 18:51
奇怪,我记得我有放缩网址,怎麽点进来後不见了@@ ※ 编辑: zzss2003 (60.248.26.157), 01/09/2018 09:17:44
5F:推 LPH66: 缩网址是 ppt 的话请换一家 01/09 09:28
我是用Imgur ※ 编辑: zzss2003 (60.248.26.157), 01/09/2018 14:19:31
6F:→ MOONRAKER: 还是看不到红线啦 什麽都没看到 01/09 14:58
拍谢!已补上! ※ 编辑: zzss2003 (60.248.26.157), 01/10/2018 09:53:58
7F:→ phishingphi: 目前我看到的红线文字为 If a set of defines 01/14 01:09
8F:→ phishingphi: applies to a particular piece of global data 01/14 01:10
9F:→ phishingphi: (such as a flags word), the defines should be 01/14 01:10
10F:→ phishingphi: immediately after the data declaration or 01/14 01:10
11F:→ phishingphi: embedded in structure declarations, indented to 01/14 01:11
12F:→ phishingphi: put the defines one level deeper than the first 01/14 01:11
13F:→ phishingphi: keyword of the declaration to which they apply. 01/14 01:11
14F:→ phishingphi: 不负责的解读成某个资料结构先宣告出来,那些相关的 01/14 01:14
15F:→ phishingphi: defines出现的位置,要嘛是在那个 data structure 後 01/14 01:15
16F:→ phishingphi: 不然就是 embedded 在 structure 里面并且缩排。 01/14 01:16
17F:→ phishingphi: 比如说一个 struct audit_context 用某个 enum 01/14 01:24
18F:→ phishingphi: audit_context 表示其状态,他应该在规定那个 enum 01/14 01:24
19F:→ phishingphi: 出现的次序为何 01/14 01:25
20F:→ phishingphi: enum 应该出现在那个 struct 之後或者包在 struct 内 01/14 01:27
21F:→ phishingphi: 并且要缩排一层 01/14 01:27
22F:→ phishingphi: 额刚刚看了第三段,他的defines 好像是 macros 那麽 01/14 10:14
23F:→ phishingphi: 就把例子里的enum改成#define 不过大概的意思是那样 01/14 10:14
24F:→ phishingphi: 没改变 01/14 10:14







like.gif 您可能会有兴趣的文章
icon.png[问题/行为] 猫晚上进房间会不会有憋尿问题
icon.pngRe: [闲聊] 选了错误的女孩成为魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一张
icon.png[心得] EMS高领长版毛衣.墨小楼MC1002
icon.png[分享] 丹龙隔热纸GE55+33+22
icon.png[问题] 清洗洗衣机
icon.png[寻物] 窗台下的空间
icon.png[闲聊] 双极の女神1 木魔爵
icon.png[售车] 新竹 1997 march 1297cc 白色 四门
icon.png[讨论] 能从照片感受到摄影者心情吗
icon.png[狂贺] 贺贺贺贺 贺!岛村卯月!总选举NO.1
icon.png[难过] 羡慕白皮肤的女生
icon.png阅读文章
icon.png[黑特]
icon.png[问题] SBK S1安装於安全帽位置
icon.png[分享] 旧woo100绝版开箱!!
icon.pngRe: [无言] 关於小包卫生纸
icon.png[开箱] E5-2683V3 RX480Strix 快睿C1 简单测试
icon.png[心得] 苍の海贼龙 地狱 执行者16PT
icon.png[售车] 1999年Virage iO 1.8EXi
icon.png[心得] 挑战33 LV10 狮子座pt solo
icon.png[闲聊] 手把手教你不被桶之新手主购教学
icon.png[分享] Civic Type R 量产版官方照无预警流出
icon.png[售车] Golf 4 2.0 银色 自排
icon.png[出售] Graco提篮汽座(有底座)2000元诚可议
icon.png[问题] 请问补牙材质掉了还能再补吗?(台中半年内
icon.png[问题] 44th 单曲 生写竟然都给重复的啊啊!
icon.png[心得] 华南红卡/icash 核卡
icon.png[问题] 拔牙矫正这样正常吗
icon.png[赠送] 老莫高业 初业 102年版
icon.png[情报] 三大行动支付 本季掀战火
icon.png[宝宝] 博客来Amos水蜡笔5/1特价五折
icon.pngRe: [心得] 新鲜人一些面试分享
icon.png[心得] 苍の海贼龙 地狱 麒麟25PT
icon.pngRe: [闲聊] (君の名は。雷慎入) 君名二创漫画翻译
icon.pngRe: [闲聊] OGN中场影片:失踪人口局 (英文字幕)
icon.png[问题] 台湾大哥大4G讯号差
icon.png[出售] [全国]全新千寻侘草LED灯, 水草

请输入看板名称,例如:Boy-Girl站内搜寻

TOP