错误检查Makefile的行为 [英] Error checking behavior of makefile

查看:110
本文介绍了错误检查Makefile的行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我的程序必须针对不同的结果(主要是错误)返回不同的值(例如0、1、2、3等),则调用该程序的makefile必须停止执行其余的makefile命令.即使该命令产生了错误(返回非零值),有没有办法继续执行makefile?

If my program has to return different values (e.g. 0, 1, 2, 3, etc) for different outcomes (mostly errors), the makefile that calls this program would have to stop executing the rest of the makefile commands. Is there a way to continue executing the makefile even if that command produced an error (return a non-zero value)?

谢谢大家.

推荐答案

mycommand; test $? -gt 3 

根据需要更改测试.我认为使用--k并不是一个好主意,因为它会阻止make检测错误.

Change the test as appropriate. I don't think using - or -k is a good idea, as it will stop make from detecting errors.

请注意,在生成文件中时,这2条命令必须位于同一行.

Note the 2 commands MUST be on the same line, when in a makefile.

在评论反馈之后添加: 您还可以执行以下操作,以允许您在对错误做出反应之前无条件运行后续命令:

Added after comment feedback: You can also do the following, to allow you to unconditionally run follow-on commands before reacting to an error:

mycommand; status=$PIPESTATUS; follow-on-command && test $status -gt 3

这篇关于错误检查Makefile的行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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