Simplified .NET assembly library

xiaoxiao2021-03-06  40

.NET library to simplify assembly of: ZDNET www.ASPCool.com Time: 2002-5-3 15:55:08 Views: 4601

The managed C of Microsoft .NET ultimately greatly simplifies the way the construction is more accurate .NET installation library. This simplification is mainly caused by the self-description characteristics of the assembly space. What is the meaning of the managed C programmer? In fact, in the case of establishing a traditional C library, various headers that are carefully created in the assembly code are no longer necessary in the assembly code (except for maintenance purposes). From a personal point of view, I think the maintenance header file is painful, so I am of course very happy that these headers can disappear from my perspective. When programming, I often forget one or more header files you need to use to index library, and I have to find the contents of the file to retrieve the definition of the lost data type. Worse, the source code is divided into two semi-orders, I have never worked in the case of correcting the wrong situation. For example, I often commit such a mistake, forgot to pack all the included files or let. H and .cpp files do not keep synchronization. Since the assembly is no longer needed, you can construct source files with new, improved methods. But before discussing these methods, let's see what happened to see what the traditional way to create assembly is. The traditional method of creating a library is like this, first establish a set of header files for each function within the library. Then, all features defined in these header files are implemented in each source file. Each source file operates a target file after compiling the header file, and all target files are connected to form a library file. Figure A shows the above traditional procedure. What is the traditional way of creating a library to use these headers? The reason is that there are them, and all classes, structures, and variables can be easily defined when citing classes later. The same way can also be used to produce assembly. The only difference is that the managed C logo must be set. The following examples shown in Listing A, B, C, and D are explained on how to create assembly with a traditional C method. Listing A shows the content in the cards.h header file. This file defines the Enum Type Suits class and CARD class in the Cards namespace. Note that in the managed C language, keyword public should be placed in front of ENUM and classes, both require public access. Listing B shows the implementation of the constructor and members of the class. List C defines the second class: deck. Note that the CARD class is used inside the DECK class, however there is no declaration to it in its header file. In fact, during the compilation process, the header will paste the entire bunch of passets into the source file. So, we can include a card.h file before the dec kP.h of the defk.cpp source file. In this way, the CARD class is first pasted, and thus, the DECK class also has a need for a definition. Listing D shows the source file that finally generates the library. Note that as we mentioned earlier, Card.h is included before deck.h. The command to create a library in the command line environment is simple. The syntax is as follows: CL Source1.cpp Source2.cpp ... SourceN.cpp / CLR / LD / O OutputName.dll C Compiler will get the list of names of the source file. Then read / clr parameters, or equal to tell the compiler that we are using managed extensions. The / LD parameter then tells the connector to create .dll, the last / o parameter tells the name of the .dll file to be created. Examples of compiled or above can be executed as follows: CL card.cpp deck.cpp / clr / ld / o cards.dll new assembly method is no longer needed to separate header files and source files, we can use new initiatives to coding.

转载请注明原文地址:https://www.9cbs.com/read-72653.html

New Post(0)