Home:ALL Converter>Conflicting types with char*

Conflicting types with char*

Ask Time:2009-05-20T09:39:39         Author:Mike

Json Formatter

I have a small program to test passing char* pointers in and out of functions. When I compile with cc, I get warning and errors saying I have conflicting types even though all my variables are char* . Please enlighten

#include <stdio.h>

main()
{
    char* p = NULL;

    foo1(p);
    foo2();
}

void foo1(char* p1)
{
}

char* foo2(void)
{
    char* p2 = NULL;

    return p2;
}

p.c:11: warning: conflicting types for ‘foo1’
p.c:7: warning: previous implicit declaration of ‘foo1’ was here
p.c:15: error: conflicting types for ‘foo2’
p.c:8: error: previous implicit declaration of ‘foo2’ was here

Author:Mike,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/885801/conflicting-types-with-char
yy