Error: Assigning to char* from incompatible type void*
11:52 20 Aug 2015

So I'm trying to store a response from a libcURL HTTP request into a C-string to be parsed later on. The response code is written entirely in C, while everything else is in C++, and with any other C++ compiler, it should work fine. But when I try to compile, even if I give the '-x c' arguments followed by the filename, I get these specific responses.

g++ main.cpp -x c cJSON.c -x c respbuffer.c -lcurl -lm

./respbuffer.c:14:9: error: assigning to 'char *' from incompatible type 'void *'
    s->ptr = malloc(s->len+1);
           ^ ~~~~~~~~~~~~~~~~
./respbuffer.c:23:9: error: assigning to 'char *' from incompatible type 'void *'
    s->ptr = realloc(s->ptr, new_len+1);
           ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~

Weirdly enough, this error only pops up when compiling with g++. If I use gcc, it works fine, and it runs smoothly enough. For the curious, I wrote everything in Xcode, and I'm compiling with GCC 4.2.1.

c++ g++