Tiny Core Linux

Off-Topic => Off-Topic - Tiny Core Lounge => Topic started by: aus9 on April 18, 2023, 12:06:37 AM

Title: [SOLVED] Fix compile error for error: implicit declaration of function makedev
Post by: aus9 on April 18, 2023, 12:06:37 AM
error may read ....while compiling, ninja etc
Code: [Select]
error: implicit declaration of function ‘makedev’ [-Werror=implicit-function-declaration]
  dev = makedev(major, minor)
above error will name filename

suggested solution

Code: [Select]
sed 's|sys/types.h|sys/sysmacros.h|' -i /pathway2/<filename.c>
ref
https://github.com/scylladb/dpdk/issues/3

Quote
This is due to the following change in glibc:

* The inclusion of <sys/sysmacros.h> by <sys/types.h> is deprecated.  This
  means that in a future release, the macros “major”, “minor”, and “makedev”
  will only be available from <sys/sysmacros.h>.

Title: Re: [SOLVED] Fix compile error for error: implicit declaration of function makedev
Post by: Rich on April 18, 2023, 05:06:43 PM
Hi aus9
... suggested solution

Code: [Select]
sed 's|sys/types.h|sys/sysmacros.h|' -i /pathway2/<filename.c> ...
That command will remove  sys/types.h  and replace it with  sys/sysmacros.h.
If  filename.c  depends on other includes or definitions from  sys/types.h  you will
introduce other errors.

Maybe something like this would be better:
Code: [Select]
sed 's|.*include <sys/types.h>|#include <sys/sysmacros.h>\n#include <sys/types.h>|' -i /pathway2/<filename.c>
If it finds  include <sys/types.h>  it replaces the entire line with:
Code: [Select]
#include <sys/sysmacros.h>
#include <sys/types.h>
Title: Re: [SOLVED] Fix compile error for error: implicit declaration of function makedev
Post by: aus9 on April 18, 2023, 06:50:30 PM
thanks Rich

until I discovered the glibc issue, my compile was failing and my above line did succeed but happy to add a new line.

Looking at your command, and matching pattern, I think I found an easier command (easier for me at my coding level)

Code: [Select]
sed -i '1aline2' /pathway2/file.c
Which translates as find line number 1....insert a new line, after line specified, with a new line that has contents "line 2" into a certain file
its shorter and only needs a text editor with line numbers or someone who can count  8)