# C 語言規格書查詢心得 ISO/IEC-9899 ###### tags: `linux2020` `C` `Q&A` ## FB社團問題: [Facebook](https://www.facebook.com/groups/system.software2020/permalink/327869394813933/) 各位晚安,我在學習week 1 bit field的時候, 因為看不懂structure 中 designated initializer 的用法 於是嘗試查詢C 語言規格書, 並把查詢的過程記錄在HackMD中, 想請問各位同學, 在遇到沒看過的語法時, 你們都是怎麼下關鍵字搜尋的呢? 有什麼訣竅能讓自己的關鍵字下得更精準呢? --------- ## 我的反思 有鑒於課程中有許多地方需要查詢第一手資料,也就是規格書 我列出了自己查詢的思路,以及各種嘗試的心得跟大家分享。 首先,根據 [你所不知道的 C 語言: 開發工具和規格標準](/@sysprog/c-standards?type=view) 內, * 葉秉哲博士的推文:「溯源能力是很重要的,才不會被狀似革新,實則舊瓶裝新酒或跨領域借用的『新觀念』所迷惑」 所以我嘗試著相同的方法,在遇到問題時, * 不先使用google查詢,而是查詢第一手資料 ISO/IEC-9899 (C99) 以下列出我的查詢紀錄 # Step 1: 列出看不懂的程式碼片段 * Where is it : in [bit-field](/@sysprog/SJ8y82ZYQ?type=view) 範例程式 ```shell course week1 └── bit-field ``` ```c=1 #include <stdbool.h> #include <stdio.h> bool is_one(int i) { return i == 1; } // a function input int main() { struct { signed int a : 1; } obj = { .a = 1 }; // struct. // obj is a structure variable. puts(is_one(obj.a) ? "one" : "not one"); // puts vs printf? return 0; } ``` * line 5: ```.a``` 的用法看不懂. * 分析```.a```中的 ```.``` 是什麼 * 根據過往經驗,英文中```.```通常唸作 "Dot". * 打開 C語言規格書,使用關鍵字 ```Dot``` 搜尋 * P.547. Index 內  * 第一個結果出現 Dot operator(structure), 在 chapter 6.5.2.3  * P.549. Index 內 * 第二個結果出現 Dot operator (union), 在 chapter 6.5.2.3 :::info 我的看法: 查詢 Chapter-6.5.2.3 可能會有結果 ::: 使用關鍵字 ```6.5.2.3``` 搜尋 * 6.5.2.3 Structure and union members * Semantics (語義的) * A postfix (後綴) expression followed by the ```.``` operator and an identifier designates (指定) a member of a structure or union object. * 綜合第五行 ```c struct { signed int a : 1; } obj = { .a = 1 }; ``` --> 推測可能與 designate a member of a structure 有關 搜尋 ```designate``` ```designated initializer, 6.7.8```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up