Makefile: Error1

前端 未结 3 1087
梦毁少年i
梦毁少年i 2020-12-16 01:45

I have a very simple c programme:

int main()
{
  return(1);
}

and a simple Makefile:

all:
    gcc -ansi -pedantic -o tmp tm         


        
相关标签:
3条回答
  • 2020-12-16 02:27

    You're returning an error code of 1 from your application. It's Make's job to report this as an error!

    0 讨论(0)
  • 2020-12-16 02:32

    Make exits with an error if any command it executes exits with an error.

    Since your program is exiting with a code of 1, make sees that as an error, and then returns the same error itself.

    You can tell make to ignore errors by placing a - at the beginning of the line like this:

    -./tmp
    

    You can see more about error handling in makefiles here.

    0 讨论(0)
  • 2020-12-16 02:49

    This is because your program is returning 1.

    Makes does the compilation using gcc, which goes fine (returns 0) so it proceeds with the execution, but your program return a non-zero value, so make reports this as an error.

    A program on successful completion should return 0 and return a non-zero value otherwise.

    0 讨论(0)
提交回复
热议问题