Is there a way to tell make to complain when I use unset variables? Something similar to set -u
in bash?
I have just spent twenty minutes debugging my Makefile, because there was a one symbol typo in the name of the variable.
Fix Notice: Undefined Variable by using isset() Function This notice occurs when you use any variable in your PHP code, which is not set. Solutions: To fix this type of error, you can define the variable as global and use the isset() function to check if the variable is set or not.
An undefined variable in the source code of a computer program is a variable that is accessed in the code but has not been declared by that code. In some programming languages, an implicit declaration is provided the first time such a variable is encountered at compile time.
Undefined variable: the variable's definition is not found in the project files, configured include paths, or among the PHP predefined variables. Variable might have not been defined: there are one or more paths to reach the line with the variable usage without defining it.
Yes, there is a way:
make --warn-undefined-variables
I've just tested it with make version 3.81
EDIT:
You can also set it in your makefile, to protect yourself in the future from silly mistakes. To do it just put this somewhere near the top of your makefile (this will be passed to recursive make processes too):
MAKEFLAGS=--warn-undefined-variables
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With