[PATCHES v2] Fix FreeBSD developer build

Uri Simchoni uri at samba.org
Thu Nov 23 08:24:33 UTC 2017


Well, it appears that due to adherence to C99, clang's inline behavior
is different.

The executive summary is:
- define the function as inline in a header file (that is, not "static
inline")
- in a single source file, declare it as "extern inline"

Example:

foo.h:
--------------
inline void foo()
{
	do_stuff();
}
---------------

bar.c:
---------------
#include "foo.h"
...
---------

baz.c:
------------------
#include "foo.h"

extern inline void foo();
....
----------------------

Without the extern bit, the code builds fine with optimization (inlining
invoked) but fails linking without.

References:
http://clang.llvm.org/compatibility.html (inline section)
https://gustedt.wordpress.com/2010/11/29/myth-and-reality-about-inline-in-c99/
https://stackoverflow.com/questions/25602813/force-a-function-to-be-inline-in-clang-llvm



On 11/23/2017 09:57 AM, Stefan Metzmacher wrote:
> Am 22.11.2017 um 21:05 schrieb Uri Simchoni:
>> On 11/22/2017 03:02 PM, Stefan Metzmacher wrote:
>>>
>>> I'm not so happy with the cflags_end change.
>>> Shouldn't we fix pidl to avoid generating unused functions?
>>>
>>> I'm also wondering what an actual example error message is.
>>> As I guess we already make sure we don't have any unused static
>>> functions with the master autobuild.
>>>
>>
>> Here's the build result with the patch removed:
>>
>> [1836/3977] Compiling default/librpc/gen_ndr/py_misc.c
>> default/librpc/gen_ndr/py_misc.c:34:25: error: unused function
>> 'ndr_sizeof2intmax' [-Werror,-Wunused-function]
>> static inline long long ndr_sizeof2intmax(size_t var_size)
>>                         ^
>> default/librpc/gen_ndr/py_misc.c:50:25: error: unused function
>> 'ndr_PyLong_FromLongLong' [-Werror,-Wunused-function]
>> static inline PyObject *ndr_PyLong_FromLongLong(long long v)
> 
> I think we should move this to a header file instead of generating it in
> each file.
> 
> Is there some documentation of the clang warnings?
> the gcc manpage says that 'static inline' functions are not subject of
> -Wunused-function
> 
> metze
> 
> 




More information about the samba-technical mailing list