I'm trying to build my library but a file called evutil.c fom libevent is giving me a hard time.
libevent/evutil.c: error: implicit declaration of function 'pipe2' is invalid in C99
The code involved is:
if (pipe2(fd, O_NONBLOCK|O_CLOEXEC) == 0)
return 0;
I can't update my code to c11 right now. How should I change the code to not get this error anymore?
implicit declaration of function means you do not have Prototypes for your functions. You should have a Prototype before the function is used. "call the block" I assume your Blocks are functions. 9/30/2020.
Function name typo: Often the function name of the declaration does not exactly match the function name that is being called. For example, startBenchmark() is declared while StartBenchmark() is being called. I recommend to fix this by copy-&-pasting the function name from the declaration to wherever you call it.
Such an 'implicit declaration' is really an oversight or error by the programmer, because the C compiler needs to know about the types of the parameters and return value to correctly allocate them on the stack.
If a name appears in a program and is not explicitly declared, it is implicitly declared. The scope of an implicit declaration is determined as if the name were declared in a DECLARE statement immediately following the PROCEDURE statement of the external procedure in which the name is used.
This isn't a C99 issue. You need to include the header for pipe2
. According to the pipe2 manual that is unistd.h
.
Why libevent isn't doing this itself is a valid question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With