Closed hesetone closed 8 months ago
I can be more helpful if I have the exact compiler error, but my assumption is that the Visual Studio C compiler is attempting to compile hiredis as C++.
Hiredis is written in C (not C++) and targets ANSI C99, which is why we pass -std=c99
in our makefile.
Can you provide more information about how you're trying to compile the project?
I can be more helpful if I have the exact compiler error, but my assumption is that the Visual Studio C compiler is attempting to compile hiredis as C++.
Hiredis is written in C (not C++) and targets ANSI C99, which is why we pass
-std=c99
in our makefile.Can you provide more information about how you're trying to compile the project?
thanks for your help, i have a visual studio project linked with an unreal engine 4.27 project, redis
is a submodule of my UE4.27 plugin. there is nothing wrong with those files except hiredis.c
. compilation will broke when i call api in hiredis.c directly or indirectly( many errors will be thrown out like E0513. ).
C and C++ are somewhat compatible with each other, but this is a case where they are not. C++ won't let you coerce void*
-> someType*
without a typecast:
// No typecast required
void doSomething(void *p) {
someType *st = p;
}
// We have to typecast the `p` variable
void doSomething(void *p) {
someType *st = (someType*)p;
}
So what I assume is happening is that the compiler is trying to compile hiredis as C++ code, instead of C code. That said, I don't use Visual Studio or Windows, so I'm not really sure how you would go about fixing it.
C and C++ are somewhat compatible with each other, but this is a case where they are not. C++ won't let you coerce
void*
->someType*
without a typecast:// No typecast required void doSomething(void *p) { someType *st = p; }
// We have to typecast the `p` variable void doSomething(void *p) { someType *st = (someType*)p; }
So what I assume is happening is that the compiler is trying to compile hiredis as C++ code, instead of C code. That said, I don't use Visual Studio or Windows, so I'm not really sure how you would go about fixing it.
there is also so much appreciation for your replay, i have found some tips. in order to fix it, i defined functions in redis.cpp manually and it really works fine. this can prevent compiler from turning to hiredis.c and compile errors disappeared.
Hi: there is a question during compiling hiredis.c, a lot of compiler [E0513] would be thrown out. just like in line 182
it shows that
type void* cannot be cast to redisReply*
, there are many errors inhiredis.c
like it. how can i fix it in VS2022?