Delphi compile instruction

xiaoxiao2021-03-05  50

Delphi's compile instruction {$ IFDEF WIN32} - this is not annotation! For Delphi, the content between left and right braces is annotation, but "{$" (Turn the currency symbol after the left parentheses) for Compiler The specifier is not annotation, but written to Compiler. Applying timid and occasion Delphi has a lot of compiler Directives (compiler instructions), what is the impact of our program development? Can they help us? COMPILER Directive's impact of program development Yes, you can discuss from the following directions: Reuse and management settings to assist in the wrong version of the classification process Unified Enforcement Environment Assistance to the Error Skilled Programming Demo is often in the process of developing the application system, especially Mrouting procedures or feedback verification procedures, these unproced programs have an extremely positive feature for software quality. However, if you don't need these additional programs, if you don't need these additional programs, you don't need to find out which programs in a bunch of programs and delete or set it to annotations, not only tiring, and it is easy to mistaken. These defect procedures are still used in the future. At this point, if you can apply Compiler Directives like $ IFDEF, you can easily indicate Delphi to / don't submit a segment program in the execution file. At the same time, Compiler itself also provides some erroneous inspection switches that can be written in advance to probably possible issues, which also help to write the right procedure. In addition to the above-mentioned unligrated version / formal version of the above-mentioned category, the version classification is classified as the "Trial version" "Popular Edition" "Professional Edition", or via the use of Compiler Directive, the final product setting is different. Use permissions. Other global version management such as "Chinese version" "Japanese version" "International Standard Edition", etc., the same can also be regarded as needed to indicate which resource files specifically for Delphi or which appropriate programs are used. In the two examples above, all versions can only share the same program code. Delphi 1.0 has many differences from Delphi 2.0. The component resource file (.dcr) is one of the cases, the archive format of the two is not compatible, after you read this article, I believe that such a program can be written, indicating Delphi Different versions use the appropriate resource file to facilitate the installation of the component. {$ IFDEF WIN32} {$ r xxx32.dcr} {$ ELSE} {$ r xxxx16.dcr} {$ Ednif} The reuse and management of the program After the previous discussion, I believe that you are not difficult to seeing Compiler Directives on program management. Application value. For the reuse and management of the original program, the Compiler Directives makes the power. For example: the PASCAL-style string is a significant difference between Delphi 1.0 and Delphi 2.0, except for the original short string, Delphi 2.0 There are also more convenient use of long strings, and the system also provides a string handling in TRIM (). If you have a string processing unit that must be applied to the Delphi 1.0 and 2.0 project, the compile indicator can help you. In addition, through Compiler Directives like {$ I xxxx}, we can also include some programs, which also help to cut a combination of our programs or compilation settings. Set the consistent execution environmental project team, must have a common environment setting, I am difficult to expect a group of members to have different {$ b} {$ h} {$ x} settings between each other, last subsystem What happens when you enter the main program. In addition, when you write a component or unit, you can use the compilation indicator to ensure that the component user has the same compilation environment. Using the Compiler Directives instruction syntax, Compiler Directives seems to be similar from the outside table. Different from the annotation: Compiler Directives starts with "{$", no splines, one name (or one letter) indicates to give Compiler's special instructions, coupled with other switches or parameters, and finally the end of the command is the end of the instruction, for example: {$ b } {$ r-} {$ r mycursor.resor, just like Pascal variables Like the reserved word, Compiler Directives is not case sensitive.

From the syntax format of the instruction, Compiler Directives can be further classified into the following three formats: Switch Directives This directive is a single letter to connect " " or "-" symbols in a single letter; or switch The name is connected to "ON" or "OFF" in a space to represent the role / turn off a compilation indicator switch. For example: {$ A } {$ align on} The compilation instruction of the switch is not necessarily branch, which can be combined between the same compilation indication, but must be connected in a comma, and there is no space in the middle, for example : {$ B , H , T-, J } The cursor holds Ctrl OO when the cursor is in any location of the program editor, and the complete Compiler Directives will be listed on the top of the Unit. Parameter Directives Some Compiler Directives need to connect to a custom parameter behind the compiling name (file name or specified memory size), for example: {$ r mycursor.res}, that is, when the Delphi is compiled, incorporates "MyCursor.res" this resource file. Conditional Directives Indicates that compiler is in the process of compilation, selectively adopted / excludes program code for different regions as set by the condition. The following is an example of compilation, the first and third columns are written to compiler, indicating that compiler compiles the showMessage () program in the __debug's condition name completes the definition; contrary, if __debug is not defined If this program is almost unreported, Compiler will turn a disappearance. {$ IFDEF __DEBUG} showMessage (INTSTR (I)); {$ ENDIF} How to change the Compiler Directives set from Delphi's IDE program, which is very convenient to modify the settings of each Compiler Directive, method is : From the Delphi IDE master: Project / Options / Compiler, direct check / cancel each Checkbox. It is worth noting that changing a project's Compiler Directives does not affect other items, in other words, each project has a compilation indication of its own set. If you want other projects, there is a "default" option in the lower left of the above ProjectOptions dialog box, after selecting this Checkbox, although there is no effect on existing projects, but new projects in the future This set of settings can be used as the default value. Setting the Compiler Directives write program to set the Compiler Directives that compiler Directives is really simple, but in many cases we still need to add Compiler Directive to the program. There are at least two reasons to support us: Local control compilation Conditions in Project / Options / Compiler settings, affecting the entire project, if a segment should be specifically used to use different compilation settings, it must be directly Compilation indication is added to the program. The following sections take the ONLINE HELP program example, that is, the application {$ I} Compile instructions local control should not happen to make an exception message when an I / O error occurs, so we can compile a program area in this program area. A file detection function that does not generate an I / O exception message.

Function FileExists: boolean; var f: file; begin {$ I-} assignfile (f, filename); filemode: = 0; (set file access to read only} reset); Closefile (f) ; {$ I } fileexists: = (iiResult = 0) and (filename <> '' '); END; {FileExists} Progressive portability we may use the Unit or Component of other companies or personal creations, It is also possible to share the program to other people, in other words, units or programs may compile them on different machines, directly adding the Compiler Directives to the program, not only can you need to specifically change the iDE before using the program, more importantly, solve The various units require different compilation environments. Note The role of Compiler Directives is like the visible range and lifecycle of variables. You must also pay attention to the scope of each Compiler Directive when we use Compiler Directives. Compiler Directives It can be divided into the following two: Compiler Directives in the whole country, affecting the entire project; we will make an overseas way to change the COMPILER DIRECTIVES in the whole country in the future, which is the whole area. And only from the line of Compiler Directives, until the end of the program unit (Unit) or another of the same compiler Directive, there is no effect on other program units. That is, if in the Unit, in the Unit, COMPILER DIRECTIVES Compiler will prioritize the settings of the area, and then the whole domain setting belongs to the project level. It is worth mentioning that the maximum role range of the COMPILER DIRECTIVES directly in the program is limited to that unit, for other units and There is no impact, even in the use of Uses reference. That is, we can refer to other Unit disclosure variables and functions through Uses, but the compilation instructions of each Unit will not reference each other. This independent nature makes Uni The setting and relationship between the compilation environment is very simple. For example, the VCL of Delphi 2.0 is compiled in {$ H }, so the strings in the VCL are compiled with long strings. The independent features of this compilation command are independent, regardless of the settings in our Prject, these strings defined in the VCL are long strings. Our Project does not change its own settings because of Unit in the VCL. Therefore, when we hand over the program to the network, you can add the necessary Compiler Directives in the program, don't worry, even if you do other Unit reference our programs, you don't affect its original settings. If we define a conditional symbol with {$ define _debugversion} ($ Define in a later personal instruction introduction), this new condition symbol is also an area, in other words, it is only from the definition After the column of the unit, of course, it is only valid for this unit. Since the conditional symbols are only the role of the area, if there are several program units need to refer to a condition symbol, what should I do? Well! In-a program unit is plus compilation indication is the most direct way, but it is a slightly trouble, especially the compilation indication is changed, and it is easy to correct because of negligence. A relatively simple and feasible approach is to fill in the condition name from the main options of the Delphi IDE integrated development environment - Project / Options / Directories / Conditional's CONDitionals. In this way, with respect to each Unit of the project, there is a standard symbol of the whole country. Alternatively, you can also refer to this article for {$ I} COMPILER DIRECTIVE.

I pointed out another elastic solution. After modifying the compilation instruction, it is recommended to pass all programs. Try this program: procedure tform1.button1click (sender: TOBJECT); begin // ifopt is used to detect a model of compilation switch {$ iFopt H } Showmessage; {$ else} showMessage ('h-' '); {$ ENDIF} end; when we execute the above program, it is $ H when Delphi preset is ShowMessage () "H " will be displayed on the screen, after executing, let the program and the contents of the form remain unchanged, simple from the primary option: Project / Options / Compiler, clear the checks of the HUGE STRINGS ($ H-), Then press F9 to execute, 咦! How can I still see "H " ?! This is because Delphi will only re-translate .pas into .dcu after the Unit content is active, in our example, the program does not change Of course, .dcu is of course not re-generated, and finally. The part of EXE is naturally no change. So, to solve this problem, just indicate that Delphi recompiles all programs as Delphi IDE master Project / Build All. Therefore, if you modify Compiler Directives from Delphi IDE, remember to build all! Should not be used as a program execution process to control in the program, we can use the IF narrative, according to the process of execution of the program, But we can't use {$ IFDEF} to do the same thing, why? From the above description, I believe you can't find it. Compiler Directives will directly affect the content of the ultimate .exe, the application is {$ IFDEF} indication Compiler's results, almost the authorization of Compiler automatically select / discard the program to .DCU, .exe, in other words, when the program is completed, it is set, we Naturally, it cannot be used to control the process of program. When the conditional compiled nest, you can include another {$ IFDEF} in a {$ IFDEF}, but only 16 floors can be included in a 1 {$ IFDEF} # {$ ENDIF} condition. Although it is a constraint, it should be enough in normal situations. Some Compiler Directives should not be written in the Unit to be like {$ minstacksize} {$ maxStacksize} management stack size, or like the {$ appty} indicator compiled into a graphics / text mode, only written in .dpr It is no effect in UNIT. The recommendation is determined that your understanding of the impact of the instruction is directly and far-reaching because the impact of compilation instructions is so straightforward. When you modify and apply a Compiler Directive, please make sure you have learned its meaning and influence. Open all the detection of the detection of the detection, compiler Directives as follows: $ HINTS ON $ D $ L $ Q $ R $ WARNINGS ON ED Usage Usage You can refer to this chapter later of the instructions for individual instructions, all open these switches. ! This not only allows you to use the Delphi IDE's removaller, but the problem in compilation and execution process, Delphi will also respond to the right time to write the correct program. There is a distress to clarify here - "Add DUBUG information will not make the execution file becomes slower?", Not necessarily. For those switches such as $ D , $ L , $ Hints, after opening, Delphi does add some atmospheric information when compiling, so that .dcu's file is large, there is no impact on .EXE file size; At the same time, the execution speed of the program has not changed, and the IDE can be applied to the apparatus Trace Our program, which is worthwise.

For Compiler Directive like $ Q, $ R, it is indeed the size and speed of the execution file, but this does not shake us to use their decisions during the R & D, please think about it, to give up the program for this point Is the correctness? Of course, after the program is developed, the version of the official shipping can close the two switches. If you write a component, and only prepare .dcu, because there is no .pas available to Delphi IDE's Debugger tracking program, the extension switch should be closed before the component is shut down and recompiled .dcu, otherwise it will cause the user The exception information of the file is not found. Good use {$ I} {$ I filename} is a very useful Compiler Directive. Apply this instruction, we can flexibly manage the set of Compiler Directive. Condition Name Please join the preamble I don't know if you have this question - What happens if the condition name defined by {$ define} is the same as the variable name is the same as the variable name? Procedure TFORM1.BUTTON1Click (Sender: TOBJECT); VAR TEST: Integer; Begin {$ define test} {$ ifdef test} showMessage ('Test'); {$ ENDIF} end; the above program compilation and execution is no problem, but the condition name is repeated with the variable name to be confused, Therefore, if appropriate, the program is more readily read before the compilation condition name is added. After you understand the Compiler Directives, you will start to modify the various switches related to the compilation indication in your IDE and set to Default, so that your project and even the R & D team will have a joint compilation. The environment, what is the way to compile the connection to the chest for the program, which is directly helpful in the subsystem into the main system. Individual instructions have previously, after the concept of Compiler Directives, the next section will introduce several commonly used Compiler Directive usage and precautions, you can learn more from this section about Compiler Directives. Knowledge and use details. The {$ A } field is aligned in the case of {$ A } (default), if there is no Packed modifier declared RECORD type, its field will be able to access 1. 2. 4 and other boundaries with the CPU. Align to get the best access speed. The following procedure is exemplary: {$ A } type MyRecord = record ByteField: byte; IntegerField: integer; end; # procedure TForm1.Button1Click (Sender: TObject); begin ShowMessage (IntToStr (SizeOf (MyRecord))); end The result of showMessage is: "8"; if it is {$ A-}, the result of the result is "5", which is reasonable, Byte should be enough, but considering hardware The execution characteristics, the aligned Record will have a better execution speed. The matters related to this compiler Directive are: regardless of the {$ A} switch is ON or OFF, using the PACKED modified record declaration, it is not aligned. For example: myRecord = packed record // will not align record Declaration {$ appType GDI} Application type Generally, Delphi generates a graphic user interface program in the way {$ appType gui}, if you need a program that generates a text screen mode, that can be: Add {$ appType console} from the.DPR from the main option: Project / Options / Linker / Exe and DLL Options, check the "Generate Console Application" Check Box.

Other considerations for this Compiler Directive include: $ appType cannot be applied in a DLL project or a single program unit (Unit), it is only for .exe meaningful. And only written in .dpr. We can apply the ISCONSOLE function in the System program unit to detect the type of application during program execution. See Object Pascal Handbook Chapter 13 You can know more about Console Mode Application. {$ B-} Boolean evaluation, please see the following procedures: if (language (ScheckedDateString) <> 8) or EMPTYSTR (ScheckedDateString = ''. '') Or (ScheckedDatestring = '' / / ') THEN Begin Result: = true; EXIT; END; if the content of ScheckedDateString is "85/12/241" (length 9), the above IF is sentenced to the result, it is already known when the first logic is determined. Even if you don't look at the logical operation results, you will know that the whole child will be true. If you wish to perform a complete assessment of the entire logical expression - although the results are known, the later logical operation does not affect the entire result, please set all the results, please set this Compiler Directive to {$ B }, Please set it to {$ b-}, the default value of the system is {$ b-}. {$ D } Inappropriate Information When the program is compiled with {$ D } (default), we can use the DEBUGER setting breakpoint of Delphi to integrate development, or use the Trace INTO or Trace Info to track the execution process, It is worth noting that the speed of executing is not affected by {$ D }, but the archive length of the compiled DCU will increase, but the size of the EXE file is unchanged. {$ DEFINE Condition Name} Defining Condition Name With your understanding of Compiler Directives and deepening to your application, you will find that this is a very useful compilation indication. Often, we will use or exclude a certain segment of programs because of the extension needs, differences from different versions, and you want to select or exclude a certain program. At this time, we can first define a condition name with $ define, then cooperate with {$ IFDEF Condition Name} # {$ else} # {$ ENDIF} Indicates that the compiler is available in the specified condition name to select the program that needs to be compiled. The following program segment: {$ define _proversion} # procedure tform1.button1click (sender: Tobject); begin {$ ifdef _proversion} frmprint.showmodal; // a {$ else} showMessage ('' Sorry, trial version Do not provide print function ''); {$ ENDIF} END; the compiler will select the programs that compile the above A, in the future, if we need to compile the "simple version" version, as long as: will {$ define _proversion} That column is deleted. Or, change {$ define _proversion} to {- $ define _proversion}, let it become a normal annotation or, add {$ undef _Proversion} in {$ define _proversion}, release _Proversion " definition. In this way, because the condition of _PROVERSION is not defined, Compiler will only select the program under {$ else}, recompilation, do not cost too much strength, it is easy to make "simple version" If you save the trouble of maintaining two procedures at the same time. Other precautions when using $ define are as follows: The condition name defined by {$ define} is area.

In other words, its role range is only valid at the unit at the time, even if it is defined in Interface in Unit, it is not effective by other Unit to use Uses reference, and it is still only available in the current Unit. In addition, its role range is from the definition, until the Unit is ended or in {$ undef}. If you have defined a condition name in {$ define} in the program unit, and no {$ undef} is unfinked, re-{$ define} There is no effect, in other words, they are the same. If necessary The condition name of a whole country, you can: Primon: Project / Options / Directories / Conditional Conditionals fill in the condition name. The following standard condition name is Delphi 2.0 has been prepared in advance, we can reference directly, while they are all domains, any unit can be referred to. VER90: The version number of Delphi Object Pascal. 90 shows version 9.0, and if there is a version 9.5 in the future, there will be a definition of VER95. Win32: Points to current Win32 (95, NT) job Environment CUP386: This condition name is provided when using a 386 (inclusive) CPU. Console: This symbol will be defined when the application is compiled in the screen mode. {$ Description Description Extracts Apply {$ description} You can specify a module description entry entry point (module description entry) to join a text to .exe or .dll, usually we will use this Compiler Directive to join the application name and version Number to .exe. For example: {$ Description DCHAT VERSION 1.0} {$ x } Densitive Syntax This is for the previous PASCAL version forward-compatible compilation instruction, although the instruction of this switch is still active, but the author recommends that you can reserve the system. Default {$ x }, under {$ x }: No need to prepare a variable acceptance function, in other words, the transfer value of the function can be discarded, at this time, it can be like a call program. Very convenient call function. A string that supports PCHAR type and zero-based character arrays as a string ending with NULL. {$ HINTS OFF} prompts the message switch {$ hints} Switch, Compiler will prompt the programming the following: the variable defines whether the for or While loop that does not execute in the program process is not available. Specified narrative. It means that after specifying data to a variable, there is no program reference to take this variable value. {$ Hints on} procedure mytest; const _false = false; var i, j: integer; begin if _false the for i: = 1 to 3 DO; J: = 3; end; {$ hints off} Due to simpler, Two programs in the middle of $ hints, we are not difficult to see: The for loop will not perform, I have never used J: = 3 to write is equal to white-written, the longer the program, the longer, and borrow It is more likely to detect the problem of problems. {$ IFDEF} {$ IFDEF} See {$ define}, this additional instructions {$ IFNDEF}, the following programs, that is, when indicating that compiler is not defined when _test is undefined, the condition is compiled with the ShowMessage (). Procedure: {$ IFNDEF _TEST} showMessage ('' _ test not define '); {$ ENDIF} In other words, {$ IFNDEF} is equivalent to {$ IFDEF} section. {$ IFOPT switch} to the bottom {$ b} is open or crosing? If we want to indicate that compiler as the status of our designation, what should we do? At this time, {$ ifopt} I gave it to the field.

For example: {$ R } {$ q} // Special specified as q- {$ i p} // If the Range Check is turned on showMessage ('program is'') in the Range Check Turn on State; / / This Q will notify Compiler {$ {$ IFOPT Q } showMessage ('q); {$ ENDIF} showMessage () and {$ ENDIF} showMessage () $ Q } will be compiled in the case of $ R , so although we are especially instructing to {$ q}, the second showMessage () can also see "Q also turn it on when the program is executed." . {$ ImageBase file basic address} This compiler directive is used to indicate the preset address when .exe or .dll load. For example: {$ ImageBase $ 00400000}. If you already have other modules to be occupied before the loaded address space, Windows reconfigures a new load address for .exe. For .dll, if you can successfully configure the address we write in {$ ImageBase}, because you don't need to reconfigure the memory address, not only the speed is faster, if you have other programs, you can also reduce this DLL, you can also reduce The load time and memory consumption are consumed. Task Note When using this Compiler Directive, you have: The specified narrative must be a 32-bit integer value greater than $ 00010000, at the same time, 16 bits in the lower position must be zero. The DLL suggestion address ranges from $ 40000000 to $ 7FFFFFF, which can be applied to Windows 95 with Windows NT at the same time. {$ I File Name} Infault to modify Compiler Directives in Delphi IDE, but often need to add Compiler Directives to the program directly, but when we do this, you will find that you want to re-modify each one by one. When these Compiler Directives in the unit, it is really boring and easy to make an error. At this time, if you use the {$ I file name}, the whole thing will become very simple. What to do? Let me tell you in an example - first build a MySet.inc's ordinary text file with the general instrument editor, the content is: {$ h } {$ define _proversion} In our program, join A column {$ I mySet.inc}, for example: unit unit1; {$ I myset.inc} interface usage {$ r * .dfm} procedure tform1.button1click (sender: TOBJECT); begin {$ ifdef _proversion} showmessage ('' Professional Edition ''); {$ else} showmessage ('' only professional version has this function ''); {$ ENDIF} END; this is the concept of subroutine! Yes, it is so simple, then if there is Any change, modify mySet.inc, then Project / Buile All, it is simple enough. After the basic action will, let me tell you more about the {$ I file name}. Once the {$ I file name} is applied, almost equal to Compiler is compiled, let Compiler put this file in the location in our program. If there is no expansion, Delphi presets this file is .pas. If this file is not found in the directory of the project, Delphi will searche by directory in the library path in Tools / Options / Library.

In addition, when you write a DLL, the user must declare before using the function, if you can provide the declaration files for these functions, users can only be {$ I xxx}, is it very convenient? {$ I } EinouTerror Check the program compiled in the {$ I } (system default), once an I / O error occurs, will raise an exception to EinouTerror, if we don't want this exception in specific cases At the time of the message (such as whether the detection file mentioned above exists), you can set this Compiler Directive to {$ I-}. At this time, whether the program is executed, the programming staff must check iResult this. The value of public variables, if it is zero, indicating that there is no error, non-zero error code, please check the online help. {$ L file name} Connection target file If you have a .Obj file to incorporate Delphi programs, you can add: {$ l other.obj}, you can use the programs in Other.obj, It is worth noting that the function or program must still declare using External before the call, indicating that these modules are from the "external". For example, the author has a .Obj file provided by KeyPro, in use, the relevant procedures are as follows: {$ {$ f } Procedure Hasp (Service, Seedcode, LPTNum, Pass1, Pass2: Word , VAR P1, P2, P3, P4: Word; External; {$ f-} After the {$ L Hasptpw.obj}, the other parts of the program can call the HSAP in Hasptpw.obj, which is originally located in HASPTPW.OBJ. . {$ L } Area symbol information When {$ 1}, Delphi will add some area symbol information, which makes we can apply View / Call Stack in Delphi IDE, View / Watch checks variable content and functions when execution Call relationship. Application of this Compiler Directive has: {$ D-}, {$ 1} does not work. Using {$ 1 }, only increase the file size of the .dcu, the size of the .exe has no effect. The {$ H } long string declares Delphi 2.0, the string has more than a more difficult long string, not only without the limitation of the data length 255 and the NULL-TERMINATED STRING compatibility of C language is also greatly improved. Precautions when using {$ h}: {$ h } Compilation scenario, string variable defined by String is a long string, please note that the string is determined when the string is defined when the string is defined. , For example: procedure tform1.button1click (sender: Tobject); {$ h-} var s: string; begin {$ h } s: = 'test a long string'; windows.MessageBox (0, pchar) s), '' message '', 64); END; due to Var {$ h-}, although we immediately set to {$ h } after BeGin, but S is still a short string, so, Naturally, it is not like a long string, and it is used as a null-terminated string after PCHAR. Bearing, regardless of the program is {$ h } or {$ H-}, as long as the string is defined in a long string, even becoming..End; is changed to {$ h-}, the operation of the string is still Features with long strings. Therefore, since the strings in the VCL are long strings, even if our programs are {$ h-}, they can still use them as a long string. Regardless of the status of {$ h}, it is a long string defined by ANSISSTRING; it is a short string defined by String [n] or shortstring.

{$ M 16386, 1048576} Memory configuration size To change the above-STACK memory configuration, we can have the following two options: Use {$ minStacksize digits}, {$ maxStacksize digits}, specify the smallest. Maximum Stack, respectively. Size. Or use {$ m min, max}, and specify the minimum and maximum value. Precautions when using these Compiler Directive: Write in .dpr. The minimum number of stacks must be between 1024 to 21474835647. The maximum number of stacks must be between $ MINSTACKSIZE to 21474835647. When memory is insufficient, the smallest stack is not satisfied, Windows will make an error report when starting this program. The Estackoverflow exception will be raised when the program requires more than $ minStacksize. {$ Z1} The smaller list size This Compiler Directive will affect the least values ​​required to store the minimum required. If the value is not present, the value is not more than 256, and it is also in the system preset {$ z1}, this listing is only stored in a BYTE. When {$ z2}, in two Byte stores, {$ z4}, stored in four Byte. Because the C language is usually stored in Word or DWORD, if your program needs to communicate with C, C , {$ z2} {$ z4} is used to use {$ z }, corresponding to {$ z-} To {$ z1} and {$ z4}. {$ P } Open string parameters When the program is declared, the string independent variables, when {$ P } is Open String; {$ P-}, just a general string variable. This Compiler Directive only has functions when {$ H-}. {$ O } optimization switch suggests that you maintain the system default value of {$ O }. Open this Compiler Directive, Delphi will automatically perform optimization, and the program can run fast, you can safely open this compilation switch, Delphi does not perform unsafe optimization to make your program execute errors . {$ Q} full overflow check, {$ r-} Range Check {$} with {$ R} is a set of useful Compiler Directive, which will check if the value or array is in a secure boundary, { $} Checks an integer operation (such as , -, ABS, SQR, PRED, SUCC, etc.), and {$ R} checks if the overhead of the array is exceeded by the reasonable boundary. Using these two Compiler Directives will reduce the speed of the program due to these checks, and we will open the two compilation switches when we are in the wrong. {$ U-} Pentium CPU floating point operation security check Remember something incorrect in early Pentium CPU floating point? This batch of CPUs should be almost the same, but if you still don't sure the program will encounter a missing network If the fish or black cardboard dealer, please set this Compiler Directive to {$ U }. According to the instructions of the Borland manual, if the CPU is ignorant, set {$ u } Only slight effects on execution speed; but if it is a problem CPU, the floating point division speed will be three times slow, do you want to open this Switch, you should have a place in your heart. {$ R File Name} The resource file has appeared in your program before you haven't started learning Compiler Directives, and when you open a new Form, Delphi is automatically added to the beginning of the Implement. R * .dfm}, there is also {$ r * .res} in the .dpr program seen in Project / Source, what do you mean? Mean that in the compilation link, income and project master name .Res, and resource files such as .DFM with the Form Unit file. If you need to use additional resources in the program (for example: self-proclaimed mouse pointer), be careful not to change these resource files with Project or Form or the resource files that are the same as Project or Form, and change the files of these same names not only by resouse Workshop or Image Editor. Invalid, there may be unpredictable errors.

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

New Post(0)