Re: [問題]如何去get C variable的scope ?

看板PLT (程式語言與理論)作者 (godfat 真常)時間17年前 (2008/06/26 12:14), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/3 (看更多)
※ 引述《allstarschh (allstars)》之銘言: : 這裡面.......好像就沒有scope的information??? : 或者是由上面的某個memory address來知道scope information?? gdb 我沒用過,不過既然是 lexical scoping, 那麼 compile time 即可確定 name resolution, runtime 完全用不到這個資訊,當然就會丟棄了 : 不過在maint print symbols : 可以看到有Blockvector 的東西 : 而這block number 的index : 就跟我說的scope number 一樣 : 由這個Blockvector 就可以來作variable的binding了 我查了一下 maint print symbols, 好像是 gdb 的功能? 也就是說,如果你用 gcc 開 debug 模式,可能抓得到這個資訊吧? 不過這理所當然不是標準 c 就是了 你是想做什麼東西?為什麼需要這個資訊? 也許必須用一些間接方式才行,例如如果是 c++ 的話, 把你的 get_scope_number_and_print(); 改成某個 scope guard 之類的 -- Hear me exalted spirits. Hear me, be you gods or devils, ye who hold dominion here: I am a wizard without a home. I am a wonderer seeking refuge. Sacrifice -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.128.121.85
文章代碼(AID): #18OnUdIr (PLT)
文章代碼(AID): #18OnUdIr (PLT)