簡體   English   中英

typedef在內部如何工作?

[英]How does typedef work internally?

隨着問題的發展, typedef在內部如何工作?

PS:我確實在包括Wikipedia在內的各種網站中進行搜索。 但是他們都沒有回答。 因此是一個問題。

為了進一步澄清:我確實了解了它的作用,但是它的作用是問題。

typedefC的關鍵字,它為程序員提供了一個工具自己的別名的工具

data type與其他類型的或現有的內置類型。

這就是語言的方式以及實現方式。

typedef <given_type> <new_type>

僅供參考:如果您這樣做

int a由編譯器解析,然后得知aint類型的變量。 並因此分配了所有內存。

同樣,只要找到typedef關鍵字,它就會假定緊隨其后的類型是old_type ,其他新標識符是new_type

編輯:

ISO c99:存儲級說明符

The typedef specifier is called a ''storage-class specifier'' for syntactic convenience only.If, in a parameter declaration, an identifier can be treated either as a typedef name or as a parameter name, it shall be taken as a typedef name.A typedef declaration does not introduce a new type, only a synonym for the type so specified

沒有指定任何編譯器如何處理typedef 類型信息很可能被保存為該名稱的符號表條目的一部分,並且在源代碼中遇到類型名稱的任何地方,都將在轉換過程中替換等效的類型信息。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM