In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
The concept of functions is supported in makefile, and the make interpreter provides a series of functions for makefile to call. Support custom function implementation in makefile and call execution; provide define keyword to implement custom function. Here is the syntax for a custom function
Let's take a closer look at the custom function, which is a multi-line variable and cannot be called directly; secondly, the custom function is a procedure call with no return value; the custom function is used to define the command set and apply the rules. Let's take the code as an example.
.PHONY: testdefine func1 @ echo "My name is $(0)" endefdefine func2 @ echo "My name is $(0)" @ echo "Param 1 = > $(1)" @ echo "Param 2 = > $(2)" endefvar: = $(call func1) new: = $(func1) test: @ echo "new = > $(new)" @ echo "var = > $(var)" $(call func1) # @ echo My name is func1 $(call func2, D.T.Software, delphi_tang)
Let's take a look at the compilation results.
We see that the new variable prints only the preceding, and not the func1, because the custom function is essentially a procedure call and does not have any return value, while var is preceded by call, so it outputs the function name func1. When call func1 is done directly, the print is the defined string, and its parameter 0 is the function name; when call func2, two parameters are added, so parameter 1 is D.T.Software and parameter 2 is delphi_tang. Let's take a look at the calls to predefined functions in the following format
So why are custom functions and predefined functions called in completely different forms? Let's analyze the predefined functions in makefile. In fact, custom functions in the real sense are not supported in makefile. Custom functions are essentially multiline variables; predefined call functions pass parameters to multiline variables when they are called. Custom functions are arguments to call functions and are executed in call.
Let's take the code as an example.
PHONY: testdefine func1 @ echo "My name is $(0)" endefdefine func2 @ echo "My name is $(0)" endefvar1: = $(call func1) var2: = $(call func2) var3: = $(abspath. /) var4: = $(abspath test.cpp) test: @ echo "var1 = > $(var1)" @ echo "var2 = > $(var2)" @ echo "var3 = > $(var3)" @ echo "var4 = > $(var4)"
Abspath in the program is the absolute path to the output of the current directory. Let's take a look at the results.
We see that var1 and var2 define a custom function, respectively, so output the function name; var3 is the absolute path to the output current directory, and var4 is the test.cpp path under the output current directory. That's exactly what happened. Through the study of the function definition and call in makefile, the summary is as follows: 1. The make interpreter provides a series of functions for makefile to call; 2. The custom function is a multiline variable and cannot be called directly; 3. The custom function is used to define the command set and is applied to the rules; 4. The predefined call function passes parameters to the multiline variable when it is called 5. Custom functions are arguments to the call function and are executed in call.
Welcome to learn makefile language, you can add me QQ:243343083.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.