could the call function in makefile call two macros simutaneously?
时间: 2024-02-17 19:04:13 浏览: 76
Yes, the `call` function in Makefile can be used to call multiple macros simultaneously. To do this, you can use the `$(eval ...)` function to evaluate a sequence of multiple macro invocations as a single unit.
Here is an example that demonstrates how to use `call` to invoke two macros simultaneously:
```
define macro1
@echo "This is macro1"
endef
define macro2
@echo "This is macro2"
endef
define call_both_macros
$(eval $(call macro1))
$(eval $(call macro2))
endef
all:
$(call call_both_macros)
```
In this example, we've defined two macros `macro1` and `macro2`, and then defined another macro called `call_both_macros` that calls both `macro1` and `macro2` using the `call` function and the `$(eval ...)` function.
When we run `make`, the `all` target is executed, which invokes `call_both_macros`. This, in turn, invokes `macro1` and `macro2`, and the output will be:
```
This is macro1
This is macro2
```
So, the `call` function can indeed be used to call multiple macros simultaneously in Makefile.
阅读全文