poke-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fix warning about 'basename'


From: Bruno Haible
Subject: Fix warning about 'basename'
Date: Wed, 24 Feb 2021 02:30:36 +0100
User-agent: KMail/5.1.3 (Linux/4.4.0-201-generic; KDE/5.18.0; x86_64; ; )

On FreeBSD 12 and Solaris (IIRC), I'm seeing this warning:

../../poke/pk-cmd-def.c:73:15: warning: implicit declaration of function 
'basename' is invalid in C99 [-Wimplicit-function-declaration]
              basename (source), first_line);
              ^
../../poke/pk-cmd-def.c:73:15: warning: format specifies type 'char *' but the 
argument has type 'int' [-Wformat]
              basename (source), first_line);
              ^~~~~~~~~~~~~~~~~
../../poke/pk-cmd-def.c:99:15: warning: implicit declaration of function 
'basename' is invalid in C99 [-Wimplicit-function-declaration]
              basename (source), first_line);
              ^
../../poke/pk-cmd-def.c:99:15: warning: format specifies type 'char *' but the 
argument has type 'int' [-Wformat]
              basename (source), first_line);
              ^~~~~~~~~~~~~~~~~
4 warnings generated.

The cause of the warning is that the basename() function has different
semantics on different systems. See
<https://www.gnu.org/software/gnulib/manual/html_node/basename.html>.
In particular, there is a conflict between POSIX and GNU. Therefore,
I propose to use the fix from the Gnulib documentation: use a differently
named function last_component().

Also, this function last_component() is already used in a couple of
other places. But the module 'dirname' is overkill for it. The module
'basename-lgpl' is the minimal module that provides this function.

Proposed patch.

Attachment: 0002-Fix-warning-about-basename-function.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]