warning:assignment makes pointer from integer without a cast

前端 未结 2 452
孤城傲影
孤城傲影 2021-01-15 06:10

Its quite a common question but I have not got my answer so asking it again.

I have structers defined as:

struct f_lock{
              int x;
                


        
2条回答
  •  -上瘾入骨i
    2021-01-15 07:07

    I seem to remember getting this (rather misleading) error message once when I had forgotten to declare a function as taking void which is required in c (but not c++) for functions with no parameters:

    struct f_lock *new_node()
    {
       struct f_lock *new_f_lock;
       .....
       return new_f_lock;
    }
    

    Should be:

    struct f_lock *new_node(void)
    {
       struct f_lock *new_f_lock;
       .....
       return new_f_lock;
    }
    

提交回复
热议问题