Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can make warn me, when I use unset variables?

Tags:

makefile

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.

like image 856
Anton Daneyko Avatar asked Jan 18 '13 02:01

Anton Daneyko


People also ask

How do you fix an undefined variable in a notice?

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.

How do you define an undefined variable?

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.

What is the meaning of undefined variable in PHP?

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.


1 Answers

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
like image 143
sirgeorge Avatar answered Oct 11 '22 22:10

sirgeorge