Skip to content

Compilation warning about fpconv_init #81

@graywolf-at-work

Description

@graywolf-at-work
cc -c -O3 -Wall -pedantic -DNDEBUG  -I/usr/local/include -fpic -o lua_cjson.o lua_cjson.c
In file included from lua_cjson.c:48:
fpconv.h:15:20: warning: inline function ‘fpconv_init’ declared but never defined
   15 | extern inline void fpconv_init();
      |                    ^~~~~~~~~~~
cc -c -O3 -Wall -pedantic -DNDEBUG  -I/usr/local/include -fpic -o strbuf.o strbuf.c
cc -c -O3 -Wall -pedantic -DNDEBUG  -I/usr/local/include -fpic -o fpconv.o fpconv.c
cc  -shared -o cjson.so lua_cjson.o strbuf.o fpconv.o

I cannot imagine what good the inline without body is. I've compiled with the following patch and everything seems to work fine.

From c9551b68ec78ecea8d31af41bbffc2f4a39d1965 Mon Sep 17 00:00:00 2001
From: Tomas Volf <[email protected]>
Date: Tue, 15 Mar 2022 18:30:24 +0100
Subject: [PATCH] Fix compilation warning about fpconv_init
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

In file included from lua_cjson.c:48:
fpconv.h:15:20: warning: inline function ‘fpconv_init’ declared but never defined
   15 | extern inline void fpconv_init();
      |                    ^~~~~~~~~~~

inline does not seem to do anything useful here, since there is no body
to inline. And extern is default. So let's just drop both, we get no
warning and everything still works.
---
 fpconv.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fpconv.h b/fpconv.h
index 0124908..22cab98 100644
--- a/fpconv.h
+++ b/fpconv.h
@@ -12,7 +12,7 @@ static inline void fpconv_init()
     /* Do nothing - not required */
 }
 #else
-extern inline void fpconv_init();
+void fpconv_init();
 #endif

 extern int fpconv_g_fmt(char*, double, int);
--
2.35.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions