Re: [問題] #ifdef排版問題

看板C_and_CPP作者 (簡簡單單的幸福)時間7年前 (2016/12/03 17:30), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/2 (看更多)
※ 引述《jba (簡簡單單的幸福)》之銘言: : 請問有沒有程式碼排版軟體,可以將#ifdef做巢狀排版, : 排完後,類似以下格式: : #ifdef YEAR : #ifdef MOON : #ifdef DAY : Days = YearCnt * MoonCnt * DayCnt; : #endif : #endif : #endif : 我使用AStyle這套軟體版排,排完後會變成這樣: : #ifdef YEAR : #ifdef MOON : #ifdef DAY : Days = YearCnt * MoonCnt * DayCnt; : #endif : #endif : #endif : 調整AStyle參數,仍然無法排成我想要的格式,有其它軟 : 體可以辦到嗎?請大家提供意見,感謝! --indent-preproc-block / -xW Indent preprocessor blocks at bracket level zero, and immediately within a namespace. There are restrictions on what will be indented. Blocks within methods, classes, arrays, etc, will not be indented. Blocks containing brackets or multi-line define statements will not be indented. Without this option the preprocessor block is not indented. 失敗的原因可能是要排版的區段有大括號的關係,例如: void main(void) { #ifdef YEAR #ifdef MONTH #ifdef DAY Days = YearCnt * MoonCnt * DayCnt; #endif #endif #endif } 提供一個解決方法,在左括號後加上// *INDENT-OFF*和// *INDENT-ON* void main(void) {// *INDENT-OFF* // *INDENT-ON* #ifdef YEAR #ifdef MONTH #ifdef DAY Days = YearCnt * MoonCnt * DayCnt; #endif #endif #endif } -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 218.161.26.150 ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1480757445.A.DCB.html
文章代碼(AID): #1OGf35tB (C_and_CPP)
討論串 (同標題文章)
文章代碼(AID): #1OGf35tB (C_and_CPP)