what is the difference of "+" symbol and "force" command in makefile?
时间: 2023-12-08 22:06:51 浏览: 50
In a Makefile, the "+" symbol and the "force" command have different meanings.
The "+" symbol is used to indicate that a command must be executed, even if the "-n" or "--just-print" option is used. This is called a forced execution. For example:
```
target:
+echo "This command will always be executed"
```
If you run `make target`, you will see the output "This command will always be executed", even if you use the "-n" option.
The "force" command, on the other hand, is used to force a rule to be executed, even if its dependencies are up to date. For example:
```
.PHONY: target
target:
force
echo "This command will always be executed"
```
If you run `make target`, the "force" command will cause the following command to be executed, even if the dependencies of the rule are up to date.
Note that the "force" command is not a built-in command in Makefile. It is a target name that is defined as a phony target, which means that it doesn't correspond to an actual file.
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)