cpointersgccwarnings

c - initialization makes integer from pointer without a cast and 2 more compiler errors


so I'm getting this warning:

initialization makes integer from pointer without a cast

in the following piece of code:

void receive(u_char *args, const struct pcap_pkthdr *pkthdr, const u_char *buffer)

{

const int one = 1;

int LEN = args;      /* THIS IS THE LINE */

struct ipheader *ip;

struct tcpheader *tcp;

and to be honest little newbie me is not sure what to do as almost all searches return makes pointer from integer.

I'm also getting these compiler messages:

/tmp/cci6u7NH.o: In function `main':
ChannelBunny.c:(.text+0x448): undefined reference to `pthread_create'
ChannelBunny.c:(.text+0x4b7): undefined reference to `pthread_join'
/tmp/cci6u7NH.o: In function `receive':
ChannelBunny.c:(.text+0xcb6): undefined reference to `nthol'
ChannelBunny.c:(.text+0xcdf): undefined reference to `nthol'
collect2: ld returned 1 exit status

got rid of a similar pcap problem by using -l pcap but that didn't work for the other two. It just returned:

gcc: pthread: No such file or directory
gcc: nthol: No such file or director

I'm guessing I have to download something? or is there another command I have to use. (I'm using Backtrack5 if that's of any use to you).


Solution

  • You should do

    int LEN = *args;
    

    args is a pointer, *args is the value pointed by it. Also, you shouldn't put a u_char into an int.

    For nthol: http://msdn.microsoft.com/en-us/library/windows/desktop/ms740069(v=vs.85).aspx