Translation Unit trong C là gì?

Mk đang học C, đọc đến phần translation unit thì ko hiểu nó là gì. Mn thông não giúp mk vs???!!!

Đây là định nghĩa trong C standard:
A source file together with all the headers and source files included via the preprocessing directive #include is known as a preprocessing translation unit. After preprocessing, a preprocessing translation unit is called a translation unit.

Hiểu theo định nghĩa này thì translation unit trong C là file .c đã trải qua bước preprocessing. Ở bước preprocessing thì tất cả nội dung của file được nhắc đến bởi chỉ lệnh #include sẽ được copy vào trong file .c, vì vậy nên trong C standard mới nhắc kèm đoạn "A source file together with all the headers and source files included via the preprocessing directive #include"

5 Likes

Ngoài ra các macro và các loại #if được trình preprocessor thay hết theo định nghĩa. Các chỉ lệnh #pragma vẫn được giữ lại vì nó dành cho compiler.

3 Likes
83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?