当我使用未设置的变量时,可以警告我吗? [英] Can make warn me, when I use unset variables?

查看:53
本文介绍了当我使用未设置的变量时,可以警告我吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用未设置的变量时,是否有一种方法可以让make抱怨?类似于bash中的set -u?

Is there a way to tell make to complain when I use unset variables? Something similar to set -u in bash?

我刚刚花了二十分钟调试我的Makefile,因为变量名中有一个符号错字.

I have just spent twenty minutes debugging my Makefile, because there was a one symbol typo in the name of the variable.

推荐答案

是的,有一种方法:

make --warn-undefined-variables

我刚刚在make版本 3.81

I've just tested it with make version 3.81

您也可以在makefile中设置它,以防止将来出现愚蠢的错误. 为此,只需将其放在makefile顶部附近(也将传递给递归make进程):

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

这篇关于当我使用未设置的变量时,可以警告我吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆