Note that there are some explanatory texts on larger screens.

plurals
  1. POPassing Argument x ... from incompatible pointer type
    primarykey
    data
    text
    <p>I'm getting a compiler error when trying to pass the address of an integer over to a function to be received as a pointer. This used to be working, but then I made some changes in my Makefile and now it doesn't work any longer. I doubt if it's syntax, but here it is:</p> <p>helper_funcs.h</p> <pre><code>void make_passive_connections(int *sockfd, Neighbor *neighbor, FILE *logfd, char this_router[64], struct sockaddr_in servAddr); </code></pre> <p>helper_funcs.c</p> <pre><code>void make_passive_connections(int *sockfd, Neighbor *neighbor, FILE *logfd, char this_router[64], struct sockaddr_in servAddr) { ... } </code></pre> <p>in the calling program</p> <pre><code> int sockfd; ... make_passive_connections(&amp;sockfd, &amp;neighbor, logfd, this_router-&gt;label, &amp;servAddr, &amp;num_hosts); ... } </code></pre> <p>The compiler also tells me that I am passing too many arguments. Is my computer having a bad day or what I am I overlooking?</p> <p>Here is my Makefile if it helps:</p> <pre><code>CC = gcc CFLAGS = -c -g -Wall -Wextra SOURCES = fork.c helper_funcs.c primary.c DEPS = primary.h fork.h helper_funcs.h OBJECTS = $(SOURCES:.c=.o) EXECUTABLE = primary all: $(SOURCES) $(EXECUTABLE) $(EXECUTABLE): $(OBJECTS) $(CC) $(OBJECTS) -o $@ #.c.o: # $(CC) $(CFLAGS) $&lt; -o $@ %.o: %.c $(DEPS) $(CC) -c -o $@ $&lt; $(CFLAGS) clean: rm -f *.o rm -f $(EXECUTABLE) </code></pre> <blockquote> <p>warning: passing argument 1 of ‘make_passive_connections’ from incompatible pointer type</p> </blockquote> <p>EDIT: I'm an idiot. I forgot to delete the last argument in my function call. But my main issue is why the compiler thinks that passing the address of an integer to a function that expects a pointer to an integer isn't working. Is there anything wrong with that?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload