Hoàn toàn không cần thiết kể từ khi D không một biểu tượng bao gồm các tập tin nhập khẩu, họ chỉ nhận được nhập khẩu một lần không có vấn đề bao nhiêu lần so với tờ khai nhập khẩu xuất hiện. Điều này được sử dụng trong C để điều chỉnh các liên kết cấu trúc. | The D Programming Language The D Way Completely unnecessary since D does a symbolic include of import files they only get imported once no matter how many times the import declaration appears. pragma pack The C Preprocessor Way This is used in C to adjust the alignment for structs. The D Way For D classes there is no need to adjust the alignment in fact the compiler is free to rearrange the data fields to get the optimum layout much as the compiler will rearrange local variables on the stack frame . For D structs that get mapped onto externally defined data structures there is a need and it is handled with struct Foo . align 4 use 4 byte alignment Macros Preprocessor macros add powerful features and flexibility to C. But they have a downside Macros have no concept of scope they are valid from the point of definition to the end of the source. They cut a swath across .h files nested code etc. When include ing tens of thousands of lines of macro definitions it becomes problematicalto avoid inadvertent macro expansions. Macros are unknown to the debugger. Trying to debug a program with symbolic data is undermined by the debugger only knowing about macro expansions not themacros themselves. Macros make it impossible to tokenize source code as an earlier macro change can arbitrarilly redo tokens. The purely textual basis of macros leads to arbitrary and inconsistent usage making code using macros error prone. Some attempt to resolve this was introduced with templates in C . Macros are still used to make up for deficits in the language s expressive capabiltiy such as for wrappers around header files. Here s an enumeration of the common uses for macros and the corresponding feature in D 1. Defining literal constants The C Preprocessor Way define VALUE 5 The D Way const int VALUE 5 208 The D Programming Language 2. Creating a list of values or flags The C Preprocessor Way int flags define FLAG_X 0x1 define FLAG_Y 0x2 define FLAG_Z 0x4 flags FLAGS_X The D Way enum FLAGS X .