Another miscellaneous

xiaoxiao2021-03-14  192

You can add the input value to JCOMBOX in JCOMBOX: // Assume You Have a JCOMBOX NAMED "CB" Cb.setedItTable (TRUE);

ComboBoxEditor editor = cb.getEditor (); Component component = editor.getEditorComponent (); component.addKeyListener (new KeyAdapter () {public void keyPressed (KeyEvent e) {if (e.getKeyCode == KeyEvent.VK_F5) {ComboBoxEditor editor = Cb.Geteditor (); cb.additem (editor.getitem ()); cb.editor.SetItem (null);}}});

The pop-up window is incorporated to pop up the window: var viorray = window.opener.olddata.length; CTR J ---> Automatically add addActionListener () and other codes! ! ! With CTR Shift C is very like

Start sessionserver, configure Security: Which JDK is determined by the Path environment variable, not Java-Home, such as: Path = C: /J2SDK1.4.2_04/jre/bin; d: / oracle / ora92 / BIN; D: / Program Files / Oracle / JRE / 1. 3.1 / bin; D: / Program Files / Oracle / JRE / 1.1.8 / bin; D: / Winnt / System32; D: / Winnt; D: / Winn T / system32 / wbem; "E: / Program Files / Symantec / Norton Ghost 2003 /"; C: /J2SDK1.4.2_04/ bin; D: / Winnt / System32; D: / Winnt; D: / WinNT / System32 / WBEM; D: / Program files / UltraEDit At this time, C: /J2SDK1.4.2_04/JRE/bin (Note: Not C: /J2SDK1.4.2_04/, is not very clear about the difference between the two.) . This is important for setting security. Start Tomcat: You don't have to use a startup.bat command, and use Catalina Run or Catalina Startup

To copy: c: /j2sdk1.4.2_04 E: / E: / tomcat change Oracle port: That hero can help me, I want a computer simultaneously as a web server and database server, but Oracle takes up 80 port, Web can not be used, please help me solve it, please because it is caused by Oracle Built-in Apache, you can change the application port of Apache, the method is as follows: Please modify the directory Oracle / Ora81 / Apache / Apache / Conf Two files: httpd.conf, httpd.conf.default, change the port in the file by 80 to 8080, can change the Apache's application port to 8080 port, restart Apache, the web can use 80 port, at this time Apache uses an 8080 port. If you don't know how the apache is restarted, restart your computer, after reboot, the problem should be resolved. Test found that Oracle still requires a random port and 1521 port to communicate with the random port and 1521 ports, but do not change with the client session and login, is not to restart the server. stable. (Test found, in dedicated mode, each connection, the Oracle server will press 1, provide a non-1521 port.) So, you also need to add a parameter in the init.ra file: mts_dispatchers = "(Address = (Protocol = TCP) (port = myoradb) (port = 1521) "" There are many solutions to random ports, usually to open Shared Socket function under Windows, so in the registry hkey_local_machine / Software / Oracle User0 set Uses_shared_socket = true, carefully tried to succeed. It turned out that Oracle8 was heard. I didn't expect Oracle9, very good. MTS (multi-threaded server) configures in the init.ora file, the parameter setting of the init.ora sample is shown below: mts_dispatchers = "IPC, 1" MTS_Dispatchers = "TCP, 1" MTS_MAX_DISPATCHERS = 10 MTS_SERVERS = 1 MTS_MAX_SERVERS = 10 MTS_SERVICE = Test mts_listener_address = "(ADDRESS = (Protocol = IPC) (Key = Test))" MTS_Listener_Address = "(Host = 10.74.72.42) (port = 1526))" regedit command editing registry .

HTTP 500, 503 error is a servlet program error, 400, 403 may not be able to find a servlet. If the Applet JAR package is not authenticated, the security exception will appear. Lesson: If the settings of a property have no effect, you can try the final setting of this property in the program, because it is too baked, it may be ok, and it is overwritten later. PRM_TR = EVAL ("TR" i); can be obtained by a string, the ID of the object is the string. Lessons: In the old ESSP, "MII undefined" error occurs when you submit a modification in the page F006_top_list.jsp, where MII is company code. The reason is: In the method wait (), the parameters of setTimeout () are compID, and there are two ways: setTimeout ("Wait ('" ")", " TRID ") ", 50); -" correct : Add ICompID plus single quotes setTimeout ("" iCompID "," Trid ")", 50); - "Error: This expression may be Wait (MII, 12), and MII is undefined Object. How do you set SYSTEM Property - log4j.configuration before starting Tomcat? - set the environment variable CATALINA_OPTS is set TOMCAT_OPTS = -Dlog4j.configuration = foobar.lcf -Dlog4j.configuratorClass = com.foo.BarConfigurator or set TOMCAT_OPTS = -Dlog4j.configuration = file: / c: /foobar.lcf1 keep in mind: in. URL midpread path. .. //logs//debug.log, or single slope will be ingore2. Class for Applet - Servlet communication and its members to serailizable. 3. If a class is always reload, you can consider restart Tomcat, empty Workdir, in the JBuilder Rebuild Web. 4.IN The Java World, Use "/" Replace of "/" Which is buy in window.5.net use //10.2.222/IPC full / del type c: /bat/a.txt Display files in the console A.TXT content. CLS clear screen 6. Search strings in the file. Find [/ v] [/ c] [/ n] [/ i] "String" [[DRIVE:] [PATH] filename [...]] / v Displays all rows that do not contain specified strings. / C Displays only the number of rows containing strings. / N Display line number. / I Search Strings Ignore the case. "String" Specifies the text string to search, [Drive:] [Path] filename Specifies the file to search. If there is no specified path, Find will search for the text that is typed or generated by another command. 7 START CMD / K new opens a window running command cmd. Soft-ICE is undoubtedly the most important tool 8 in the dynamic debug field. Rononce -P ---- 15 seconds shutdown 9.

The path / lib / usr / lib / usr / local / lib / usr / lib / usr / local / lib / usr / lib / usr / local / lib is in the three paths below, we may not specify the path. 10. Sometimes we use a function, but we don't know the name of the library. What should I do this time? I am sorry, I don't know the answer for this question. I only have a stupid approach. First, I went to the standard library path. Look for a library that is related to the function I use, I found the libctor file (libpthread.a). Of course, if I can't find it, there is only one stupid method. For example, I am looking for SiN This function is located. Just use nm -o /lib/*.so|grep sin> ~ / sin command, then look at ~ / sin file, go to the inside. In the SIN file, I will find Such a line of Libm-2.1.2.so: 00009fa0 w SIN, I will know that SiN is in the libm-2.1.2.so library, I use the -LM option (remove the previous LIB and the back version flag, There is still M. So -LM). 11. Header files and system help sometimes we only know the general form of a function, do not remember the exact expression, or don't remember that the function is explained in that header file. At this time we can help the system.

For example, we want to know the exact form of the FREAD function, and we will export a detailed explanation of a function. The header file in which the function is located. If we want to write this function, when we execute When Man Write, the result of the output is not what we need. Because we want the Write this function, it is a description of the command of Write. In order to get the Write function, we have to use Man 2 Write. 2 It means that the WRITE function we use is the system call function, and there is a library function we use 3 indicating that the function is C.

Remember when, MAN is our best assistant.

13. When the connector is running, it first scans the input file, finds the size of each segment, collects all symbol definitions and references. The connector creates a segment table record input file, a symbol table records all imported or imported symbols. With the data obtained by the first pass, the connector assigns a digital address for each symbol, determines the size and position of the segments in the output file, and calculate where the individual sections need to appear in the output file. Secondary scanning uses information collected in the first pass scan to control the actual connection process. The connector reads and overloads the target code, replacing the symbol to the digital address, adjust the memory address in the code and the data in the data to reflect the segment address after the overload, write the overloaded code to the output file. Finally, the output file is written along with head information, overloaded segment and symbolic table information. 14. Each global symbol is started by a underscore, which is described in Chapter 5. 15. Any address of any N-byte data must have at least log2 (n) low zero. No alignment data will cause performance reduction, Program errors are also caused in some systems (most RISC chip systems). Many processors have aligned requirements for program instructions, and most RISC chip requires instructions to be aligned to 4-byte boundaries. 16. From a connector's point of view, the connector needs to be adjusted to the byte boundary, so the connector does not need to consider instruction coding. 17. Until the year, the addressable memory becomes large, if you can save the entire address space, you can save too much, still very valuable memory space. In order to solve this problem, the computer designer cancels the direct addressing method in some or all of the instructions, and uses the index and the base register to provide some or all of the number of bits used in addressing. The instructions can become shorter, but causing more complex programming. 18. If you have a big change, compile and run all the problem, then you can all Checkout once. If Tomcat has an inexplicable problem, you can: 1) Compile the entire project 2) Clean web module, build web module 3) Replace Tomcat 4) If 1, 2, 3 does not care, then it may be a source program or package problem, extreme It is possible that there is a program or package is not available. CHECKOUT throughout the CVS. 5) If it is Run Essp, then remember to start the session server. 19.log4j.properties in the middle of the line: log4j.rootcategory = INFO, stdout must have, it makes all logs have an appender - stdout. If not, then the LOG defined in log4j.properties will not find Appender. For example, category log = category.getinstance (mytest.class.getname ()); it is not defined in log4j.properties. 20. In Strust If If you can't find it in StrustConfig.xml, it will be wrong: the picture does not come, and there is no prompt information.

In fact, if the following dependence is not satisfied, it will be wrong: the picture does not come, no prompt information, enter: 1) a) StyleID is defined in the .css file, if not, the control is placed in flowLayout, and there will be no errors. b) beanname = "qtactvform" defined in struts_config.xml: Reference for this form: In FQC01020_QTACTVAction for this FORM value: Request.SetAttribute (" QTACTVFORM ", RTNActionForm); in these four locations: beanname (JSP), Name (Struts-Config .xml's Form-bean tag), Name (Struts-config.xml action tag), key (in the Action class) If 1, 2, 3 names are different, the value of the controls in the JSP cannot be Transfer to the action; if 1, 2, 4 names are different, the value in the Action to the request cannot be automatically set to the JSP. The names of these four locations do not cause exceptions or errors, and the screen will be displayed. C) Name = "QualityActivity" Specifies an attribute of the Form - QTACTVForm. Note: Case sensitivity. Typically: in server.ssp.qc.qtactv.form.fqc01020_qtactvform.java: Private string QualityActivity; if QualityActivity is not a property in form - qtactvform, then an error: The picture is blank.

2) This specifies the URL of the Action submitted by the form, it is to be defined in struts-config.xml: is an action Path = "/ QTACTV" in the label. If you can't find the action of the "/ QTACTV" URL in Struts-Config.xml, then it will be wrong: the picture is blank or the following error message appears: org.apache.jasper. JaspeRexception: Cannot Retrieve Mapping for Action / QTACTV. 3) This label is defined in struts-config.xml. Represents a steering URL. Quote this Forward in Action, enter the turning page: return mapping.findforward ("qtactv"); if "QTACTV" can't find it in Struts-config.xml, then the turned page is blank. 21. If the value of one attribute in the FormBean is NULL, the control with the same name will display the default value (ie, value = "xxx" written in JSP). If null indicates "no value", this situation should be avoided if "no value" instead of "default". For example, when this value is NULL, it is set to "". twenty two? How does Message display? How to automatically verify data? After submitting the form, the page in the action is always turned on in a new window, how do you open a new window. The table's CSS style is not defined (how to pay attention to data, not to display) How to make the table in the HTML like Applet: Title is fixed, and the scroll bar will automatically appear when the data line is many. How to capture the rows of the table click, double-click the action. When modified, new, how to make TABLE synchronization after deleting a data? Is it refreshing? When there is a control variable, it is placed in the FORMBEAN or not in the FormaBean (use request.getParameter () in the action)? How does the error message of the servlet end? Whether the frame structure can be written into a template. 22. Usage of MD21: 1) E: / BAK / 0706 / MD21 / Samples / Config / Database Configuring Database, MD21 is based on this configuration to generate the XML and Java files of all tables of the database.

2) E: /BAK/0706/md21/samples/build.xml There is a line in the specified database profile: 3) Start the database (for example MYSQL Database) 4) Run commands: Ant -f e: /bak/0706/md21/samples/build.xml Specifies the correct Java data type for each field of the desired table in the generated graphical interface. Click the Generate button to generate an XML file under the E: / BAK / 0706 / MD21 / Samples / Build / Gen-SRC / ESSP / TABLES folder. 5) Run command: Ant -f e: /bak/0706/md21/samples/build.xml HBM2JAVA will generate Java under the E: / BAK / 0706 / MD21 / Samples / Build / Gen-src / ESSP / TABLES folder file. This step is actually generated in accordance with the XML file. 23. RTEXPRVALUE: Whether to support runtime expressions, that is, if the value can be specified <% = ABC%>. For example: /> in which RTEXPRVALUE = false, the value of the value attribute is RTEXPRVALUE = True. (I guess Type is the specified value) 24. Request Scope: The object within Session-Scoped is available throughout the session. The object within Page-Scoped is available in a specific JSP page. It can be considered that the object within the partial variable of JAVA classes corresponding to the JSP is available in the current request / response cycle life period. It looks very similar to the page-session, but for example, when the JSP page uses the redirection () When the browser is sent to another page, the object is still available. Objects within Application-Scoped are available in any request in the web application. 25. The Java code written in JSP is called Scriptlet, such as: <% = Request.getParameter ("name")%> Scriptlet's annotation mode: <% - this is a comment. -%> 26.PageDesign Problem: Cactless FORMBEAN, which makes it specified for FORMBEAN and is useless. If you specify a request, generate the JSP "Please refresh the page information" how to specify the previous control, the latter control. 27.attribute type invalid accounting to the specified TLD This error is because this tag in the TLD file does not define the attribute type.28. In the query analyzer in SQL Server: Insert Into [UPLOAD_LOG_TEMP] Select * from [fa] [dbo]. [UPLOAD_LOG] Where modifydate = '2004-05-04 00: 16: 07.000'

Sometimes you want to specify Table (FA) and Roles (DBO) 29.jsp Compilation Experts: Quote Symbol Expected, because the value of the property of the tag must be expanded with quotation marks. For example, 30. Strange JSP compile, run error: org.apache.jasper.jaspeXception at Org.JaspServletWrapper.Service (jspservletWrapper.java: 254) AT Org.apache.jasper.servlet.jspservlet.Servicejspfile (jspservlet.java: 295) at Org.Apache.jasper.Servlet.jspservlet.Service (jspservlet.java: 241) ............. ............................... [error] org.apache.struts.taglib.tiles.inserttag $ INSERTHANDLER.DOENDTAG ( INSERTTAG.JAVA: 922) - servletexception in '/qc/qtactv/fqc01020qualityActivityListContent2.jsp': null org.apache.jasper.jaspeXception ...................... .................... ApplicationDispatcher [/ CRM]: servlet.service () for servlet debugjsp threw exception org.apache.jasper.jaspeException: servletexception in '/ QC / QTACTV / FQC01020QualityActivityListContent2.jsp ': null ...................................... ... The above is a summary. The reason is that a forced type conversion is wrong: ((FQC01020QualityActivityform) Onebean) .Getrid () should be ((FQC01020QualityActivityVbean) onebean) .Getrid () Who can see the reason from this phenomenon? 31. When a Java file is generated, why is there a function call corresponding to a function, some TAG corresponds to a code? For example, TAG is a corresponding piece of code. is a corresponding function call.

32. If the form's method is get, then the address of the submitted page will see the parameters of the question mark connection, the shape is: http: // localhost: 8080 / CRM / QC / QTACTV / QUALITYACTIVITYINSERTATION.DO? FOCUS_NAME = Production & list_start_index = - 1 & subsessionid = & change_flag = & cancel_flag = & forward_path = & querystring = & back_path = & context_path =% 2Fcrm & url_suffix = .do & text_length_evaluation_mode = byte & rid = & qualityActivityType = 5 & qualityActivity = & production = & productionUnit = & method = & criterion = & remark = & productionSizePlan = 0 & densityPlan = 0.00 & defectRatePlan = 0.00 & productionSizeAct = 0 & densityAct = 0.00 & defectRateAct = 0.00 & caseact = 0 & DefectAct = 0 & btnok = btnok33.tiles Tag Page Properties: where URI is the root directory of relative applications. For example, the full path is /crm/layout/tabbedlayout.jsp. Don't add more / CRM more, or it will become /crm/crM/Layout/tabbedlayout.jsp. More BT is, you can't find a file will not report an error. If the page specified by Page does not have a corresponding Java file generated, then more than half of the specified file cannot be found. 34. jsp unclear as following exception: ApplicationDispatcher [/ crm]: Servlet.service () for servlet debugjsp threw exception org.apache.jasper.JasperException at org.apache.jasper.servlet.JspServletWrapper.service (JspServletWrapper. Java: 254) at Org.Apache.jasper.Servlet.jspservlet.Servicejspfile (jspservlet.java: 295) at Org.Apache.jasper.Servlet.jspservlet.Service (jspservlet.java: 241) Most of the more than an abnormality, such as empty pointer.

35. When defining an action in Strust-Config.xml If the FORM property is not specified, the following exception appears: unretrieve form null on action ... If this action does not appear in the JSP (ie Form's action attribute The value) does not seem to have the above exception. 36. Consider the following exception is why: org.apache.jasper.JasperException: /qc/qtActv/defect/FQC01021DefectUpdate.jsp(42,33) equal symbol expected at org.apache.jasper.compiler.DefaultErrorHandler.jspError ( DefaultErrorHandler.java:94) at org.apache.jasper.compiler.ErrorDispatcher.dispatch (ErrorDispatcher.java:428) the reason is that there is an illegal character: in There is an illegal character behind the attribute Name. 37. Plus on a file plus: <% @ page contenttype = "text / html; charset = GBK"%> Otherwise Chinese characters may have garbled. 38. 1: Table column is not Qi 2: How to adjust the CSS style, such as the background of the label color? Is the holistic style to think about the Japanese? --No! ! ! I still think that the absolute position will make the code a lot! Otherwise, if you add a control, then multiple programs add this control, and each program adds layout code. If you use absolute positioning, simply change the CSS file and add this control in each file. 39. The following exception: org.apache.jasper.jasperexception: No getter method for Property of Bean Webvo is that there is no property in the bean. 41. Native2JAVA turns the following questions when the Chinese characters are converted to UTF-8: "Please select the quality goal to delete." -> "/ u7487 / u5cf0 / u539b / u95ab / u590b / u5ae8 / u7455 / u4f78 / u57b9 / U95C4 / U3087 / U6B91 / U7490 / U3129 / U567A / U9429 / UE1BD / U7223 / U9286 / UFFD last quotation. The solution is to add one or more spaces at the end.

42. The above value property is important, it is the default value. If Request.GetParameter ("RID") is null, then its value is the value specified by value. If it is not specified, null. If there is no parameter rid, no value specified, then it will exceed the exception. Very strange, this exception is not reported in Tamcat. ----> Check the source code is very hard. There is also the same problem today, but I didn't find the reason. Because you cannot debug the ParameterTAG class in Struts. Depressed 43. When compiling Struts with ANT, I encountered a strange problem. If the compiled classpath contains struts.jar, then compile is wrong; it is fine after deleting it. There will be a version of the JAR package when compiling with ANT, such as commons-logging-api.jar and commons-logging.jar, a new one after another. It is best to use the latest. 44. Card number: 2781436590. Order number: 3818804

// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------------------- http://www.linuxforum.net/forum/postlist.php? Cat = & Board = Program & Page = & view = & sb = & o = // - ------------- Learning BAT file ----------------------- 0. If the command is too long, you can wrap, wrap The character is '^', which is like writing is the same. Note Be careful when setting up the environment variable: "SET A = 1", this means that the value of the environment variable 'a' is '1', is it very strange! ! And when Windows is sensitive to the path, do not end with '/' when the value of the general environment variable is one path. Think as Windows thinks C: /TEMP//a.txt does not exist. 1. Output to the character output to the console: >> Command: NET USE> A.txt Write the output to file a.txt (output result is to print to the console). NET USE >> A.TXT adds the output results to file a.txt. 2, @ @echo off - @ @ 的 让 后 @ 部分 部分 部分 部分 部分 部分 部分 部分 部分 部分 部分 部分 部分 部分 简 打 打 出 出 出 3 打 3 出 3 3 3 3 3 3 3 3 3 3 3 3 3 3 Yes, the comment command, in the batch script and the REM command equivalent 5 ,: and goto goto is a jump command,: is a tag, as follows: echo begin goto end :: Jump to the label END Echo Skip this line: end :: Define a label, and "end:" echo end end is a label if you do not define an end, an error is reported to specify the label - end, but the previous statement will execute. The characters behind the label will be ignored: Echo End of End Echo End is ignored. 6,% this percentage is the parameter file in the batch file QQ.BAT: ECHO% 1% 2 Execute the QQ First Second Output First Second Parameter is called "% 1", "% 2", "% 3", Plain text Replacement: Replace before execution: change the file QQ.BAT is: ECHO% 1CH% 2% 1CH% 2% 1CH% 2 Execute QQ Echo Echo Echo output to: echo echo echo output is: echo echo . Very strange: the parameter% 10 is invalid, and it is considered to be% 1 plus 0. This has a benefit: there is no confusion of% 1 and% 10 because there is no 10th parameter. 7.% Variable% Reference Environment Variable Variable: If echo% java_home% will print the C: /J2SDK1.4.2_04 is the same as parameters, which is also replaced with plain text, then execute. Does parameter% and environment variable %% are confused? No: If one% is followed by numbers,% 2 and% 2% are reference parameters 2 If one% will follow the letters, it must be referenced by the environment variable, and it must be enclosed with %%. % 2% 2 is two parameters reference% java_home% C is a reference to a environment variable and a connection of character C. 8.

To connect multiple commands in the same line, such as (echo a) & (echo b). These commands are executed in turn to connect multiple commands in the same line, such as (echo a) && (echo b). These commands are executed sequentially However, once a program performs an error, it will no longer perform the following programs. Comparison (DEL ABX) & (Echo BBBB) & (Echo BBBB) & (Echo BBB) 10. | Pipeline Command: It is the output of the previous command as an input of the next command such as the HELP command lists all DOS commands. The more command will display the string or file, if too much, will turn it over. Help | More will pass the HELP's output to more so that the DOS command is displayed in a screen. || The usage of this command is almost the same, but the role is just right with it: When using this method, when performing multiple commands, when you encounter a correct command, exit this command combination, no longer continue to execute the following command 11. <,> &, <& These orders are also pipelines, but they are generally not common, you only need to know how OK, of course, if you want to study it, you can check it yourself. <, Enter the redirected command, read the command input from the file instead of reading from the keyboard. > &, Write the output of a handle to the input of another handle. <&, Just, and> & in turn, read input from one handle and write it into another handle output. 12 Three Filters: more commands each time the screen file content or command output is displayed. The find command searches for specified characters in the file and command output. The sort command is arranged in alphabetical order and command output. To send an input from a file to the filter command, use less than symbol (<). For example: sort B.txt will sort file a.txt content, each behavior is an element, and is arranged in a small order in a small order. The result is written to the file B.txt. (Very strange, if it is sort a.txt, the file A.txt is empty; and sort > A.txt is normal.) These three commands can use pipes Command |, the output of the last command is used as its own input: DIR | FIND ".log" DIR command lists all files of the current folder, find in it .log, outputs .log. (case sensitive)

8. if if f [not] Errorlevel Number command :: Errorlevel is the execution result of the last program (can be seen as the return parameters of Main, generally success is 0, failure is 1), ErrrorLevel is also an environment variable if [not] string1 == String2 Command :: string comparison, string does not need to be enclosed with quotation marks. Unless the comparison of space-op string2 command :: string is compared to: EQU, NEQ, LSS, LEQ, GRT, GEQ: Option / i indicate comparison when comparing comparisons. If [not] exist filename command :: Determined file name exists if the file name exists if [NOT] Defined Variable Command :: Determined environment variable Variable When it defines comparison strings, if there is no character, it will be reported. The if - else else command must be on the same line at the end of the IF command. 1. Command: if exist c: /bat/a.txt. Del c: /bat/a.txt. Else Echo C: /bat/a.txt is missing. The next command of the DEL command must be stronger, and the else command must be stronger. 2. Command: if exist c: /bat/a.txt. Del c: /bat/a.txt. Else Echo C: /bat/a.txt is missing. Because the else command must be on the same line at the end of the IF command. 3. Command: if exist c: /bat/a.txt. (DEL C: /BAT/A.TXT.) ELSE (Echo C: /Bat/a.txt is missing.) Is correct. The brackets are enclosed in parentheses, then the end of the IF is right brackets). 3. Command: if exist c: /bat/a.txt. (DEL C: /BAT/A.TXT.) ELSE (Echo C: /Bat/a.txt is missing.) Is correct. The command can be enclosed in parentheses. 9. for

(The "File" in the following, the element of "SET", is not only the file, and can also perform a particular command for each file in a set of files. For% variable in (set) do command [command-parameters] (Note: In (SET), there is space between IN to the left bracket.)% Variable specifies the replaceable parameters. (SET) Specify one or a set of files. You can use wildcards. Command specifies the command to execute each file. Command-Parameters specifies the parameters specified for a specific command. (This is very simple, the elements in the Set. The elements in the set are separated by commas.) When using the for command in a batch file, specify variables, please use %% Variable without using% Variable. The variable name is case sensitive, so% i is different from% i. (Do not know "Specify variable, please use %% variable"? - Execute the for command in the console, you can use% or %% form; In the batch file, you can only use %% form. Experiment found: Specify% i, or %% I can, but the subsequent variables should also correspond to% or %%. Experiment found: If set is *, it is traversal All files of the current directory are as if specified / d.) If the command extension is enabled, the following additional for command format will be supported: for / d% variable in (set) do command [command-parameters] if The centralized containing wildcards, specify matching with the directory name without matching the file name. (Example C: / BAT> for / D% I in (C: / BAT / *) DO @echo% i output: c: / bat / d C: / bat / copy D Here the asterisk * The folder of the character, from the output can see only the folder, regardless of the file under the folder.) For / r [[DRIVE:] PATH]% Variable In (SET) Do Command [Command-Parameters] Check [Drive:] Path is the root directory tree, pointing to the for statement in each directory. If there is no specified directory after / r, use the current directory. If the set is only one single point (.) Character, the directory tree is enumerated. (For example, C: / Bat> for / r E: / Tomcat / ESSP% K in (*) do @echo% k output: E: /TOMCAT/ESSP/SHUTDOWN.BAT E: / Tomcat / ESSP / Startup. Bat E: /TOMCAT/ESSP/Runsvr.bat.bak E: /TOMCAT/ESSP/Runsvr.bat This is an asterisk * indicates that the file is only a single point (.) character, you enumerate the present The directory tree, the "enumerated directory tree" means that all of the folders and all of its jade folders, but not files.) For / l% variable in (Start, Step, End) Do Command [Command -Parameters] This set indicates a digital sequence from the beginning to the end in incremental form. Therefore, (1, 1, 5) will produce sequences 1 2 3 4 5, (5, -1, 1) will produce a sequence (5 4 3 2 1).

(It is also very simple here, line as for (int i = start; i <= end; i = step) {}) for / f ["options"]% variable in (file-set) do command [command-parameters] FOR / F ["Options"]% variable in ("string") do command [command-parameters] for / f ["options"]% variable in ('command') do command [command-parameters] or if there is UsebackQ options: for / f ["Options"]% variable in (file-set) Do command [command-parameters] for / f ["Options"]% variable in ("string") do command [Command-parameters] for / F ["Options"]% variable in ('command') do command [command-parameters] filenameset is one or more file names. Before proceeding to the next file in the filenameset, each file has been opened, read and processed. Processing includes reading a file, dividing it into a line of rows, and analyzing each line into zero or more symbols. The FOR cycle is then called with the resulting symbol string variable value. With the default, / f is separated from the first blank symbol of each line of each file. Skip blank lines. You can replace the default parsing operation by specifying an optional "Options" parameter. This band-quoted string includes one or more keywords that specify different parses options. These keywords are: eol = c - refers to the end of a row bet release character (one) Skip = n - refers to the number of rows ignored at the beginning of the file. Delims = xxx - Indicator jacket set. This default separator set replaces the space and the jumping. Tokens = x, y, m-n - means which symbols per row are passed to each iteration for itself. This can cause allocation of the additional variable name. M-N format is a range. Specify MTH via NTH symbol. If the last character in the symbol string is asterisk, then additional variables will be allocated and accepted after the last symbol parsing. Usebackq - Specify new grammar has been used under the case: Perform a back quotation string as a command and a single quotation number character is a text string command and allows double quotes to expand file names in FileNameSet.

(The expression is not very clear, the reform is as follows: Do not specify Userbackq: Set the element of the set to be included in double quotes, the grade is as a string; if the single quotes are enclosed, it is as command, the command will Pre-speech is executed (output as a set as a set). When Userbackq is specified, the elements of SET are enclosed in double quotes, then the level is as a file name. If the file name contains space, then specify UseBackQ and then use double The quotation is enclosed. If you enclose the single quotes, it is a string.) Some examples may help: for / f "eol =; tokens = 2,3 * delims =,"% i in (MyFile.txt) Do @echo% I% J% k will analyze each row in MyFile.txt, ignore those rows of the semicolon head, pass the second and third symbols in each row to the FOR program Body; with a tendon and / or space delimited symbol. Note that the statement of this FOR program references% i to acquire the second symbol, reference% J to obtain the third symbol, refer to% K to get all the remaining symbols after the third symbol. For file names with spaces, you need to create files with double quotes. In this way, use dual quotes, you also need to use the UseBackQ option, otherwise, the dual quotation marks will be understood to be used as a string to define a certain analysis. % I is specifically description in the For statement,% J and% K are specifically demonstrated by the tokens = option. You can specify up to 26 symbols via tokens =, as long as you do not seek a variable above the letter 'Z' or 'Z'. Keep in mind that the for variable name is generic;, it is not more than 52 or more. You can also use FOR / F analysis logic on adjacent strings; method is to enclose the filenameset between brackets with single quotes. Thus, the character serial will be regarded as a single input line in a file. Finally, you can use the for / f command to analyze the output of the command. The method is to turn the filenameset between brackets into a hind string. This string will be regarded as a command line, pass to a sub-cmd.exe, and its output will be grasped into memory and is used as a file analysis. Therefore, the following example: for / f "UseBackQ Delims =="% I in (`set`) Do @echo% i enumerate the name of the environment variable in the current environment. (Undoubtedly, the above is explained to the speech and clear of the for / f, and then emphasize the following: 0. The object being analyzed is the file, the string, the output of the command, if a file has 10 lines, then for loops 10 Time 1. Parameter EOL actually specifies the annotation symbol, and the row starting with the comment symbol will be ignored.

2. Parameter Delims Specifies the separation symbol, such as "Delims = A / [", specifies four split symbols, each line will be divided by these split symbols into one word 3. The content of the file is analyzed for one word, sequentially For 1, 2, 3, 4, ... parameter tokens specifies which words are output, list the serial number of the words to be output; reference these words, start from i, in turn,% i,% j,% K until, %z . You can also specify which letters start, as% a in ('set'), then the reference of the output word is% a,% B,% c can specify an asterisk *, indicating all remaining words), and for variables Reference replacement has been enhanced. You can now use the following options: ~ i - Delete any quotation marks ("), expand% i% ~ FI - expand% i to a fully qualified path name% ~ Di - expand% i to a drive number% ~ pi - only expand% i to a path% ~ Ni - expand% i to a file name% ~ xi - expand% i to a file extension name% ~ Si - the extended path only contains short name% ~ AI - expand% i to file file attribute% ~ Ti - expand% i to file Date / time% ~ zi - expand% i to file size% ~ Path: i - Find column in the path environment The variable catalog, and expand% i to the first fully qualified name. If the environment variable name is not defined, or if the file is not found, this combination key will expand to the empty string can combine modifier to get multiple results. :% ~ DPI - Expand% i to a drive letter and path% ~ nxi - only% i expand the% i to a file name and extended name% ~ FSI - only% i to a full path name with a short name % ~ DP $ PATH: I - Find the directory column in the path environment variable and expand% i to the found first drive letter and path.% ~ ftzai - expand% i to the DIR of the similar output line in the above example In the middle,% I and PATH can be replaced by other effective values.% ~ Syntax is terminated with a valid FOR variable name. Select the larger write variable name similar to% i is more readily read, and avoid confusion with the combination of regardless of case. Show, Set or delete the cmd.exe environment variable. (There is no real experiment, the above command is overall before adding some prefixes to the output words. The output word is I, or other.) 10. Set

Display, set, or remove the cmd.exe environment variable. Set [variable = [string]] Variable Specifies the name of the environment variable. String Specifies a series of characters to be assigned to the variable. Only type of SET and do not add parameters, you can display the current environment variable. If the command extension is enabled, the SET will change as follows: You can activate the set command with only one variable, the equal number or value does not display all the prefixes match the value of all variables used by the name of the name. For example: SET P will display all variables of the letter P header If the name is not found in the current environment, the set command will set Errorlevel to 1. The set command does not allow variable names to contain equal numbers. (In the following, it can be seen that the environment variable is used as a normal variable to participate in calculation, can be assigned, with constant operations, etc., which makes BAT computing in languages ​​such as Java, C. Remember parameters / A, and / P No matter what you don't believe, the set command distinguishes between spaces: 1. set list = abc 2. set list = ABC 3. SET list = ABC The above three statements are different: 1. Define variables (LIST), value is (ABC) 2. Define the variable (List), the value is (ABC) 3. Define the variable (List), the value is (ABC) and, the SET will consider all the characters on the right side of the right value, the equal sign is the variable name, However, except for connection symbols, such as &, && et al. Conclusion: Do not leave spaces on the left and right of the same level.) Add two new replacement in the set command: SET / A Expression set / p variable = [promptstring] / a command option specified The string on the right side is the evaluated digital expression. The expression evaluator is simple and supports the following operations in the order of decreasing priority: () - Group * /% - calculator - - Calculator << >> - Logic Shift - Bit "and" ^ - Bit "异" | - bits "or" = * = / =% = = - = - assignment & = = | = << = >> =, - Expression separator if you use any logic or Employ the operator, you need to expand the expression character string with quotation marks. Any non-numeric string key in the expression as an environment variable name, the value of these environment variable names have been converted to numbers before use. If an environment variable name is specified, but not defined in the current environment, the value will be set zero. This allows you to use environment variable values ​​without typing those% symbols to get their values. If set / a executes the command line outside the command script, it displays the final value of the expression. The assigned operator requires an environment variable name on the left side of the assigned operator. In addition to the hexadecimal 0x prefix, octal has a 0 prefix, the numeric value is a 10-in number. Therefore, 0x12 is the same as 18 and 022.

Please note that the octa-based formula may be easy to mix: 08 and 09 are invalid numbers because 8 and 9 are not valid eight-in-bit digits. The / P Command Option allows the variable value to set a row of entries entered. Read the input line before displaying the specified PromptString. Promptstring can be empty. Environment variable replacement has been enhanced:% PATH: STR1 = STR2% will expand the PATH environment variable, with "Str2" instead of each "Str1" in the extended result. To delete all "Str1" from the extended result, "str2" can be empty. "STR1" can be headed in an asterisk; in this case, "STR1" will remain comparable to the first occurrence of the beginning of the extended result to the STR1 remaining part. (Replace the substring STR1 in% PATH% with STR2, but does not change the environment variable PATH) or the sub-string can also be specified for the extension. % PATH: ~ 10, 5% expands the path environment variable and then only starts five characters starting from the 11th (offset 10) character in the extended result. If no length is specified, the default value, that is, the number of variable values. If both numbers (offset, and length) are negative, the number used is the value of the environment variable value plus the specified offset or length. % PATH: ~ -10% will extract the last ten characters of the PATH variable. % PATH: ~ 0, -2% will extract all characters of the PATH variable, except for the last two. (Summary:% PATH: ~ OFFSET, LEN% 1. Result is% path% [OFFSET 1, Offset LEN] Subrings 2. When the offset is negative, then OFFSET = Total length offset. Intuitively, it can be seen as It is from behind to the first OFFSET bit. When LEN is negative, then Len will no longer be the length, and see the end bit, that is, the result is% PATH% [OFFSET 1, the total length len] If the length LEN

same. The following example does not achieve the expected effect: set list = for% i in (*) do set list =% list%% i echo% list% reason is that it does not create a list of files in the current directory, and Just set the List variable into the last file found. This is also because% List% is only expanded when the FOR statement is read; and the LIST variable at that time is empty. Therefore, the FOR cycle we really execute is: for% I in (*) do set list =% i This loop continues to set the list into the last file found. Delay environment variable expansion allows you to expand environment variables in execution time using a different character (exclamation mark). If the delayed variable expansion is enabled, the above example can be written to the following example to achieve the expected effect: set var = before if "% var%" == "set var = after if"! Var! == "After" @echo if you see, IT worked) set list = for% i in (*) do set list =! list!% i echo% list% If the command extension is enabled, there are several dynamic environment variables Extensions, but do not appear in the list of variables displayed in the SET. These variable values ​​are dynamically calculated when each variable value is expanded. If the user defines any variables in these names, that definition replaces the dynamic definition below:% CD%-extension to the current directory string. % DATE% - Extensions to the current date with the same format with the date command. % Time% - Extension to the current time with the same format with the time command. % Random% - extends to any decimal number between 0 and 32767. % ErrorLevel% - Extension to the current ErrorLevel value. % Cmdextversion% - Extension to the current command processor extension version number. % Cmdcmdline% - extended to the original command line of the call command processor. (Summary: 1. set command defines variables, lines such as SET variable name = Value 2. Before any statement is executed, you will first identify% variable name%, replace the variable to its value, if there is no change, It is a normal string; for example: set list = a set list =% List% B second sentence after: set list = AB, the execution result is: the value of the List is ab. Replace only once, the replacement is no longer recognized % Variable name%, that is, no second replacement. For example: set list = a set tlist = list set list = %% TLIST %% B, the third sentence is a replacement after setting List =% List% B, execute results: The value of the List is% List B.

"A statement" refers to: a row statement - can be used &, &&, | SET LIST = a set tlist = b if list == a (set tlist = list set% TList% = aa) is executed, the third sentence is replaced with: if List == a (set tlist = list set b = AA) The result is the value of the List is a 3. Point 2 is the default execution command C: / bat> cmd / v: ON, open the "Delay Variable Switch" switch (the default is closed), this is the second point Different: "A statement" is executed, the previous replacement% variable name% "a phrase" is executed forward! Variable name! This use &, &&, |, if - else, for is a statement, composed of multiple phrases . For the above example: set list = a set tlist = b if list == a (set tlist = list set! Tlist! = Aa) is executed, the phrase set! Tlist! = AA is replaced with: set list = aa results Is the value of List to try: cmd / v: on set list = a set tlist = list for% i in (*) do set list =!% TLIST%!% I) // ------- ------- Learning makefile file ---------------------- 1. A simple makefile ### makefile start ### myprog: foo .o bar.o gcc foo.o bar.o-myprog foo.o: foo.c foo.h bar.h gcc -c foo.c -o foo.o bar.o: bar.c bar.h gcc -c bar.c -o bar.o ### Makefile End ### A simple makefile file contains a series of "rules", its style is as follows: target (prerequiries) ... command (TARGET) ...: Derequiries ...; command (Command) Command (Command), for example, the first rule in the previous example, depends on MYPROG, depending on foo.o and bar.o. The command is GCC, which has a TAB in front. If you follow the dependency, you don't need a TAB. The dependence of the target is also a goal, such as foo.c, foo.h, bar.h 2. must keep in mind that all the work is when the target (exactly the ultimate goal) needs to be updated, according to the specific rules you have developed Excuting an order. Make doesn't know how the command works.

The ultimate goal is the goal that makes Make finally updated. Other updated goals are because they serve as the dependence of the ultimate goal, or the dependence, and so on. These rules are not executed if some rules and ultimate goals have no associations. The default ultimate goal is the first target of the first rule. Exception: The target starting with the period ('.') Is not the default, the final goal can be specified in the Make command - Make Foo.O3. Execute the Makefile file 1. By default, when Make is looking for a Makefile file, it Trying to search for files with the following names, in order: 'gnumakefile', 'makefile', and 'makefile'. 2. Specify the makefile file with the parameter: make -f file1 file2 file3 can specify multiple files and will be executed in order.

4. INCLUDE: Contains other makefile files include filename1 filename2 filename3 incrude is not a command, can't start with Tab. INCLUDE contains other files. You can also specify which files containing parameters: make -include

If the Makefile file name does not start with '/', you can't find it in the current directory, you need to search for additional directories. First, search the directory specified by '- |' or '-include-Dir' parameter, then search the following directory (if they exist): 'prefix / include' (usually '/ usr / local / include' ) '/ usr / gnu / include', '/ usr / local / include', '/ usr / include'.

5. $$ - for the US Circle * for wildcard, / * as an asterisk, obviously / restores the special symbols. When defining variables, wildcards are primary, such as: objs = * .o definition OBJS is a .o file called *, not all .o files. Objs = $ {wildcard * .o} Defines OBJS for all .o files. In the rule CN game, the matching file cannot be found when the match is found, such as: myprog: * .o If there is no .o file, MyProg relies on the file * .o file. 6. Search in the directory to rely on vPath variables If a file as a target or dependencies do not exist in the current directory, Make searches the file in the directory specified by the vPath. If you find the file you want to find in these directories, just as these files are in the current directory, the rules specify these files as dependencies. In the vPath variable definition, the name of the directory is separated by a colon or space. VPATH Directive VPath Pattern Directories specifies a search path to a file name of a certain format type. The search path consists of a directory to search. The directory is separated by a colon (in the MS-DOS, MS-Windows system separated by semicolons) or spaces, and the vPath variable defines the path format to search. VPath Pattern clears the search path in connection with a certain type format. VPATH Clear all the search paths specified by the VAPTH instruction. When multiple DIRs are defined for the same pattern, these DIRs are searched sequentially, such as vpath% .c foo vPath% blish vPath%. C bar represents search`sc 'files first search for directory `foo', then` blish ', Finally `Bar '; if it is the following code: vpath% .c foo: bar vpath% blish means searching` .c' file first searches for directory 'foo', then 'bar', last 'Blish'.

Directory Search Process When searching for a file via a directory, this file may not be the dependency you listed in the list; sometimes the path found through the directory can also be discarded. Make decides that the algorithm based on the path saved or discarded through the directory search is as follows: 1. If a target file does not exist in the directory where the Makefile file is located, the directory search will be performed. 2. If the directory search is successful, the path and the resulting file are temporarily stored as the target file. 3. All the goals are based on the same method. 4. After the dependency processing is completed, the target may or does not need to be recreated: 1. If the target does not need to rebuild, the path of the file obtained when the directory search is used as the target of all dependencies, and contains the target file. . In short, if Make doesn't have to rebuild the target, you use the path to get through the directory. (? Do not understand!) 2, if the target needs to rebuild, the path of the file obtained when the directory search will be discarded, and the target file is rebuilt in the directory where the Makefile file is located. Briefly, if Make wants to rebuild the target, it is to rebuild the target in the directory where the Makefile file is located, not the path of the file obtained when the directory search is. (? Really?) The algorithm seems to be more complicated, but it can explain the things you want. Other versions of Make use a relatively simple algorithm: if the target file does not exist in the current directory, and it is available through the directory, whether or not the target needs to be rebuilt, always use the path to search through the directory. Recommendation: If the target does not with the Makefile with a directory, you should specify its path (? Good suggestion?) Connection Library Search Directory When a dependent name is '- | name', make specifically in the current directory, Under the directory of VPATH, the directory specified by VPath and '/ lib', '/ usr / lib', and 'prefix / lib' (normal case `/ usr / local / lib", but MS-DOS, MS -Windows version of Make behavior seems to be prefix defined as the root directory of the DJGPP installation tree) The directory is searching the name of 'libname.so' and then processes it. If you don't search for 'libname.so' file, search the 'libName.a' file in the aforementioned directory. For example, if there is a library file with '/usr/lib/libcursees.a' in your system, then: foo: foo.c -lcurses cc $ ^ -o $ @ 如果 "foo 'than' foo.c ' Old, will result in command 'cc foo.c/usr/lib/libcurses.a -o foo'. In fact, the conversion from '- | name' to 'libname.so' or 'libname.a' is supported by .LibPatterns variable. The default value of the .LibPatterns variable is "'lib% .so lib% .a'", which can redefine the variable, such as a null value.

3. Include rules: If a target does not have a corresponding rule (ie, it is the target instead of the target dependent), or there is no command in the rule, the implicit rules will be launched. If the implicit rule is in the final target's dependencies, it is always performed. The implicit rules of the conjugate: Compiling C Programs 'n.o' is automatically generated by 'n.c' using command '$ (cc) -c $ (cppflags) $ (cflags)'. # 即-C $ (CPPFLAGS) $ (cxxflags) 'is generated. We encourage you to use the suffix '.cc' instead of the suffix '.c' for the C source file. Assembling and PreProcessing Assembler Programs (Compilation, and Preprocessing Compilation) 'n.o' From 'N.S' Run C Compiler, CPP, Generate. The command is: '$ (CPP) $ (cppflags)'. LINKING A SINGLE Object File (Connect a simple OBJ file) 'N' Automatically generates Linker in the 'n.o' running the C compiler. Commands are: '$ (cc) $ (ldflags) no $ (loadingLibes) $ (ldlibs)' can also connect multiple OBJ files, but require the target with a dependent target, but the suffix can be different, usually omitted the dependency target Such as x: yo zo: 1. Omso on a dependency object: XO, restore to: x: XO, YO, ZO? If Xo does not exist, will this implicit rule? 2. Including Rule $ (CC) $ (LDFLAGS) XO YO ZO $ (LOADLIBES) $ (LDLIBS) -Ox Yacc for C Program (generated by YACC Generating C Programs) 'n.c' automatic by 'n.y' Run YACC generation using the command '$ (YACC) $ (YFLAGS). Lex for C Programs 'N.c' is automatically generated by 'n.l' by 'n.l'. Command is: '$ (lex) $ (lflags)'. The variables used in implicit rules include command name variables and parameter variables used by commands.

Below is a command name variable: CC C language compiler; default: 'cc'. CXX C compiler; default: 'g '. CPP with standard output C language pre-processing procedures; default: ' $ (Cc) -e '. YACC transforms the YACC language into a C program; default is:' yacc '. Makeinfo converts the TexInfo source file to the information file; default is:' makeinfo '. RM Delete file Command; default is: 'rm -f'. Here is a variable list of additional parameters for the above command. Under the case where there is no indication, the value of all variables default is null. Cflags is used for additional signs of the C compiler. CXXFLAGS is used for additional signs of C compilers. CPPFLAGS is used for C pre-processing and an additional flag (C and Fortran compiler) using its program. YFLAGS is used for additional signs of Yacc. YACC. Include rule chain: When starting an implicit rule, if the rule's dependence (possibly a file) does not exist, a new implicit rule will be launched. Pushing according to a subkey, a hidden rule chain is formed. For example: from the file myprog.y to the file myprog.o, you must first run the implicit rule YACC, followed by the implicit rule CC. Note: An intermediate file is generated when running an implied rule chain (but if files are mentioned in Makefile, it is not an intermediate file), if these intermediate files exist, they will update these files, if not, will Delete these intermediate files after updating the final goal. . Secondary: Intermediate File list. Secondary target tells Make Do not delete the listed intermediate file. AllTerMediate: Intermediate file list. AllTerMediate target tells make a list of intermediate files, even if these files may be mentioned in Makefile. No implicit rules can appear twice or more (including twice) in implicit rules chains. This can force Make to block an unlimited loop when searching for an implicit rule chain. You can regard the implied rule chain as an implicit rule. Multiple implicit rules can be applied to the same suffix. These rules will execute one of them in priority. For example: from the file myprog.c to the execution file MyProg, you can have a rule chain compile-connection, or you can directly compile and connect with the command CC. The latter rule is preferred.

2. Relying on Dependent MyProg: foo.o bar.o indicates that the target MyProg relies two objects (Target). "Relying on" means: The timestamp of the file MyProg should be compared to the file foo.o or File bar.o, if you are more than their old, you need to run the target myprog, which allows GCC foo.o bar.o -o myprog. Relying on the chain reaction, the target foo.o rely on foo.c, foo. H, bar.h, if there is a new one in these three files, allowing the target foo.o to be used to ensure that the target file and the source program (.c, all included .h) synchronization. (When using the GCC, use the -m switch, it will output a rule for each of your C file, make the target file as a purpose, and this C file and all Header files that should be killed by #include will be used as relying Document. Note that this rule will join all Header files, including the files surrounded by cornence brackets (`<',`>') and dual quotes (`"). In fact, we can quite certainly determine the system header file (such as stdio.h STDLIB.H, etc.) Will not be changed by us, if you use -mm instead of -m to GCC, the Header file surrounded by the corner parentheses will not be included. (This saves some compile time))

5. PHONY TARGETS 1, a goal is a file, a target "Relying on" another goal, that is to ensure that this file is new, if the old words, the command under this goal is performed. 2, if a target MyProg relies on another target foo.o, the target foo.o rely on the target foo.c, then executes foo.c - foo.o - myprog. 3, if a goal (actually is a file name) does not exist, then it is always the oldest. For example: All: foo.o bar.o gcc foo.o bar.o -o myprog Since the file "all" does not exist, the command GCC ... Once in the final target's dependent chain is executed. For example, Cleanall: rm * .o rm myprog cleanAll does not exist, but it doesn't rely on, so it is always the oldest, once it is performed in the final target's dependent chain. CleanAll deletes all .o and myprog files. If a destination does not exist, is it like this? 4. If a goal is not dependent, it is always the latest. (Of course, if the target does not exist, according to the rules, it is always the oldest. carried out. For example, in the previous example, the file cleanlL exists, then command Make CleanAll does not run the rule command because the target is already the latest. Obviously, this situation is avoided. The solution is: Use the target does not exist, and there is no command and dependence rules: Clean: Force RM $ (Objects) Force: make Will think that the Force rules should always be executed, the execution result is force is the latest, the target Clean will be better than it. Old, so Clean will be executed. Simply said: empty dependence is the oldest, Force reliance is the latest. These two points can be utilized. Another solution is to use .phony target, see section 5. below. 5, built-in illusion target ".phony": The system knows that it is a file that does not exist, so do not check the disk or look for implicit rules. A .phony target-dependent goal will also be an illusion target. For example: .phony: CleanAll even if the CleanAll file exists, the target CleanAll is also an illusion target. In fact, Make does not check at CleanAll's store. Generally, an imaginary goal should not be a dependence on an actual target file. 6. / One-line command is written in two lines, use "/" to connect, such as: rm Edit main.o kbd.o command.o display.o / insert.o search.o files.o utils.o

Multi-line annotations can also be used in: # line1 / line23.makefile variable example: ### makefile Start ### Objs = foo.o bar.o cc = gcc cflags = -wall -o -g myprog: $ (Objs ) $ (Cc) $ (bjs) -o myprog foo.o: foo.c foo.h bar.h $ (cflags) -c foo.c -o foo. bar.o: bar.c Bar.h $ (cc) $ (cflags) -c bar.c -o bar.o ### Makefile end ### = such as cc = GCC, to set a variable, you only write this in one line The name of the variable, followed by one = number, followed by the value of this variable you want to set. : = Such as CC: = GCC, ": =" indicates immediate assignment, in general, is the same as "=". The following situation will be different: cc = GCC CC2 = $ {CC} CC = CC This three sentences, the value of the variable CC2 is CC, not GCC. It is like CC2 and expression $ {cc} binding, When you need it, you will calculate it again: cc = GCC CC2: = $ {CC} CC = CC This three sentences, the value of the variable CC2 is GCC, not CC. The value of CC2 is immediately calculated and does not change with variables. Change changes in CC. In the future, you have to reference this variable, write a $ symbol, followed by the variable name surrounded in parentheses. Three more useful build_in variables are $ @, $

Automatic variables are built-in variables, their name is "Variable $ Name", such as $ @ automatic variable list: $ @ rule target file name. If the goal is a file member, the file name of the variable '$ @' file file. For format rules with multiple targets (see Format Rule Description), the variable '$ @' is the target file name that causes the rule command to run. $% When the target is a file member, the variable is the target member name, see Using Make to update the archive file. For example, if the target is' foo.a (bar.o) ',' $% 'value is' bar.o', '$ @' 'value is' foo.a'. If the target is not a file member, '$%' is a null value. $

These seven variables have only the path name of the file or only the variants of the file name under the directory. The variable name of the variable is composed of a variable name to add alphabet 'D' or 'F'. These variants are in a half-waste in GNU Make because the same results can be obtained using functions T DIR and NOTDIR. Refer to the file name function. Note that 'F' variants omissions all end slashes in the DIR function are here: the list of these variants: `$ (@ d) The path part in the target file name, the end slash has been removed. If the value of the variable `$ @ 'is` dir / foo.o', the value of variant `$ (@ d) 'is` Dir'. If the value of the variable `$ @ 'does not include a slash, the value of the variant is`'. `$ (@ F) 'The true file name section of the target file name. If the value of the variable `$ @ 'is` dir / foo.o', the value of the variant `$ (@ f) 'is` foo.o'. `$ (@ F) 'Is equivalent to` $ (notdir $ @)'. `$ (* D) '` $ (* f)' STEM path name and file name; in this example, their values ​​are: `Dir 'and` foo'. `$ (% D) '` $ (% f)' The path name and file name in the file member name; this is only meaningful for file member objectives in the form of 'Archive (Member)', and when the member contains path name it works. See the file member target. `$ (

5. Implied rules search algorithm This is the process of making Make as a target 'T' search for implicit rules. This process is used for any doller rules that do not have commands, which are used for the goals of ordinary rules that do not contain commands, as well as the dependence on any other rule target. This process can also be used to rendepending the rules of recursive recursions from implicit rules. No suffix rules are not mentioned in this algorithm, as suffix rules transform to format rules when the Makefile file is read. For the file member objective of 'Archive (Member)', the following algorithm repeats twice, the first time the entire target name 't', if the rule is found for the first time, the second use '(MEMBER) 'As the target' t '. 1. The path portion is separated in 't', referred to as 'd', and the remaining portion is called 'n'. For example, if 't' is 'src / foo.o', 'd' is 'SRC /'; 'N' is 'foo.o'. 2. Establish all target names to match the list of format rules of 'T' and 'N'. If the target format contains a slash, match 't', otherwise, match 'n'. 3. If there is a rule in the list that is not a multimetric rule, remove all non-final million rules from the list. 4. The rules that will not be commands are also removed from the list. 5. Format rules in each list: 1, look for STEM's', which is the 't' or 'n' part of the% match in the target format. 2. Use STEM's' to calculate the redeemed name. If the target format does not include a slash, add 'd' the front of each dependency. 3. Test all dependencies exist or can be created. (If any file is mentioned as a target or dependencies in makefile, we say that it should exist.) This rule can be used if all dependencies or can be created, or without dependence. 6. If it is not found to use the rules that can be used, further test. Rules in each list: 1, if the rule is the final rule, ignore it, continue the next rule. 2. Calculate the name as the above. 3. Test all dependencies exist or can be created. 4. For non-existent dependencies, recursively invoking the lookup in accordance with the algorithm can be created with an implicit rule. 5. Apply this rule if all dependencies or can be created with an implicit rule. 7. If there is no implicit rule, if you have the target '.default' rule, you apply this rule. In this case, the command '.default' command is given to 't'. Once you find the rules that can be applied, use STEM's' replacement% for each match (whether 't' or 'n') is used, and the resulting file name is stored until the command update target file 't' is executed. After these commands are executed, put each stored file name into the database, and the flag has been updated, the timestamp and the target file 't'. If the command of the format rule is performed, the auto variable will be set to the corresponding goals and dependencies (see Auto Variables).

4. Implicit Rules (Implicit Rules) When there is no command under a target, an implied command is called. For example, if the gcc foo.c foo.h bar.h -o foo.o is ordered, hidden commands: $ (CC) $ (CPPFLAGS) $ (CPPFLACH) $ (Target_Arch) -c $ -O $ @ 翻 翻: g g 变 自己 自己 自己 自己 自己 自己 自己 自己 自己 自己 自己 自己 自己 自己 自己 自己 自己 自己 自己 自己 自己 自己 自己 自己 自己 自己 自己 自己 自己 自己 自己 自己 自己 自己 自己 自己 自己 自己 自己 自己 自己 自己 自己 自己 自己 自己 自己 自己 自己 自己 自己 自己 自己 自己 自己Used to control the compilation process. ? Which implied rule is used for any decision. 6. Functions does not define a function in makefile, but only reference a function: $ {Function Name Space Parameter 1, parameter 2, parameter three, ...}. Quoting a function, you can assign a variable to a variable, such as the Sources = $ (Wildcard * .c) function Wildcard lists the file name of all files that match "* .c", and the result is given to the variable Source. : Objs = $ (PatSubst% .c,%. O, $ (Sources) function PATSUBST matches "% .c" string in variable $ {sources}, and replaces the string "% .c" replace "%. o ". Briefly, "c" in $ {sources} is used to represent one or more characters; wildcard * represents zero or more characters; 7. Rules Target: Components Tab Rule Every Rule must have a Tab. 7. A complex example: (Note: At the end of the line, you can't follow the comment, the following writes are just to make it easy to explain, actually use to delete these comments) ### makefile Start # ##

############################# # # generic makefile # # by George Foot # email: George.foot@merton.ox.ac.uk ##################################################################################################### user settings ## Customising # # # Adjust the following if necessary; EXECUTABLE is the target # executable's filename, and LIBS is a list of libraries to link in # (eg alleg, stdcx, iostr, etc) You can override these on. Make's # command line of course, if you prefer to do it this. # # If you need, adjust the following. Executable is the target's executable file name, libs # is a list of packages that require a connection (such as Alleg, Stdcx, iostr, etc.). Of course, you can overwrite them on the command line of make, you are willing to have no problem. # Executable: = Mushroom.exe Libs: = alleg # now alter any implicit rules' variables if you like, eg: # # Now change the variables in the implicit rules you want to change, such as cflags: = -g -wall -O3 -m486 # Include Rule Use these variables cxflags: = $ (cflags) # The next bit checks to see WHETHER RM is in your djgpp bin # Directory; if not it Uses del instead, But this can Cause (HARMLESS ) # `File Not Found 'Error Messages., # Set the variable to something which will unquestioningly remove # files. # # Let's check if there is any rm command in your DJGPP command directory, if not We use the # del command instead, but it is possible to give us the 'file not found' this error message, this is not # 大 #. If you are not using DOS, set it into a command that deletes files and unused. # (In fact, this step is redundant on the UNIX class, but it is convenient for DOS users. UNIX # users can delete this 5 line command.) IFNEQ ($ (Wildcard $ (DJDIR) /bin/rm.exe),) # Find $ {DJDIR) /bin/rm.exe file, (here is found in comparison with the air string) RM-F: = RM -F # definition variable RM-F is RM-F ELSE RM-F: = DEL ENDIF # You Shouldn't Need To change. # # # # From here, you should not need to change anything.

(I don't believe it, too NB!) Source: = $ (Wildcard * .c) $ (wildcard * .cc) # Find all .c and .cc source file list OBJS: = $ (PATSUBST% .c ,%. O, $ (PatSubst% .cc,%. O, $ (source)) # 创成 目 列 文件 列, Note: The same name. C and .cc file will generate repetition .o file DEPS: = $ (PatSubst% .O,%. D, $ (objs)) # 生成. DEPS file list missing_deps: = $ (Filter-Out $ (Wildcard $ (DEPS)), $ (DEPS) # 2 steps : 1.WildCard $ {DEPS} Find all existing .d files; # 2.filter-out will be found. Document from the list of DEPS files, the remaining is not existing .d file list # does not exist The DEPS file list is placed in the variable missing_deps. Missing_Deps_sources: = $ (PatSubst% .d,%. C, $ (Missing_DEPS)) / # minutes two steps: 1.patsubst% .d,% .c, $ {missing_deps} list all .d files The .C source file, a PATSUBST behind it (PatSubst% .d,%. CC, $ (missing_deps))) # 2.WildCard Source File list C Source File list CC to find out the source file list C and source files List CC exists Source file # Why do you have to use Wildcard after PATSUBST? Because one .d file may correspond to one .c file, it may also correspond to a .cc file, so find the actual .c or .cc file cppflags = -md #? = Self-assignment operator is very like .phony: Everything DEPS OBJS CLEAN VERYCLEAN REBUILD Everything: $ (Executable) DEP: $ (DEPS) # DEPS DEPS Rely Decou File list # Trigger an implicit command? Objs: $ (bjs) # Target OBJS Relying on the OBJS File list # Trigger an implicit command? Clean: # a false image target, does not rely on the file, does not automatically run @ $ (rm-f) * .o # delete all .o file @ $ (rm-f) * .d # delete all .d files Veryclean: Clean # A illusion depends on the description target Clean @ $ (Executable) # Delete the generated executable Rebuild: VeryClean Everything # A desynamic target, relying on Veryclean and Everything IFNEQ ($ (missing_deps),) # If there is a DEPS file (ie .d file) $ (MISSING_DEPS): # 目 目 是: d d 文件 d 文件 文件 文件 文件 文件 文件 文件 文件 文件 文件 文件 文件 文件 文件 是$ @) Endif -InClude $ (DEPS) # contains the DEPS file to makefile, with the C language #include very like, replaced for plain text.

$ (Executable): $ (OBJS) # executable file, relying on all .o files GCC -O $ (Executable) $ (OBJS) $ (Addprefix -L, $ (LIBS)) # 2 steps: 1.Addprefix - l ### append: administrator @ xty-fe540439EF0 / CYGDRIVE / D / CGWIN / XTY / SRC $ 1. $ GCC Ac-O Ao Generates AO $ GCC AC -OA Generate a.EXE $ GCC AC Generate a.exe $ GCC AO AO (.text 0x0): libgcc2.c: Multiple Definition of `maincrtstartup '/usr/lib/crt0.O (.Text 0x0): first defined here ao (.data 0x0): / cygnus / netrel / src /GCC-2.95.3-5/gcc/libgcc2.c: multip n of `__cygwin_crt0_bp '/usr/lib/crt0.O(.data 0x0): First Defined Here Collect: LD Returned 1 Exit Status $ GCC AO - NostartFiles Generate a.exe Note: When using the GCC compile source program ".o" file, you need to add a "-nostartfiles" option. This option makes the C compiler without linking the boot function in the launch function library of the system. Otherwise, you will get a "multiple-definition" error. $ GCC A.C -O A.X Generate A.X $ GCC A.X -NOStartFiles Generate a.exe Note: "Hello World" is not printed after the generated EXE run. (Is it the suffix of the target file. Xi caused?) // ----------------------------------- -ssp ----------------------------- 1. If the system becomes big, then compile and package the entire Project will take time. Consider To divide the system into a Common, subsystem, cross package, so everyone asks for Common, his own system, his own system, and other people's crossage. Other files can not be packaged .2.Parameter's name value, where the name should be All uppercases such as param.put ("name", "xty");

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

New Post(0)