Warning: implicit declaration of function 'open'; did you mean 'popen'? [-Wimplicit-function-declaration]

I'm trying to compile some c code using serial ports on 19.07.4 that works on old distributions i.e. 17.x

In my c file
#include <fcntl.h> // for open
#include <unistd.h> // for close

But I keep getting the following error:
warning: implicit declaration of function 'open'; did you mean 'popen'? [-Wimplicit-function-declaration]
someserial = open(SERIAL_PORT, O_RDWR | O_NOCTTY );

Google shows some old references to 18.04 that were fixed with an un-named patch.

Can anyone shed some light as to why it doesn't work on 19.07.4?

Hi. I think these header files are located in the toolchain.. ? Which one are you using, or which device target are you targetting?


I think your program always had this problem, but you are now compiling with a newer toolchain with a newer version of GCC which is more strict.

This happens when you try to use a function in the code before you define the function

see this