WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: [SOLVED] Fix compile error for error: implicit declaration of function makedev  (Read 2465 times)

aus9

  • Guest
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>.

« Last Edit: April 18, 2023, 03:08:17 AM by aus9 »

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11635
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>

aus9

  • Guest
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)
« Last Edit: April 18, 2023, 10:10:05 PM by aus9 »