[Top][All Lists]

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

Re: Missing extern "C" in count-one-bits.h?

From: Paul Eggert
Subject: Re: Missing extern "C" in count-one-bits.h?
Date: Fri, 21 Feb 2020 12:59:55 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0

On 2/20/20 12:15 PM, Simon Marchi wrote:
The disagreement between the symbol names between count-one-bits.o and 
seems to show that there is a missing `extern "C"` in the count-one-bits.h 

Thanks, I'll take your word for it. (I don't use C++.) I installed the attached patch into Gnulib. Apparently these modules have been used by C code only, until now.

And apparently, gcc decided to compile the definition in the header and include
it in arm-get-next-pcs.o, while clang did not.  Is that the compiler's choice,
or is it because the macros and preprocessor conditionals in count-one-bits.h
evaluated to something different for the two compilers?

It's a compiler's choice whether a function is inlined. When I call count_one_bits in C, gcc -O2 doesn't create a function for count_one_bits in the calling module; it simply issues the popcnt insn, or calls the appropriate GCC library function on platforms that don't have a popcnt insn. Perhaps you were compiling with some other level of optimization, or perhaps C++ does this differently; but regardless of how the compiler does it the resulting code is supposed to work of course.

Attachment: 0001-Add-extern-C-to-count-one-bits.h-etc.patch
Description: Text Data

reply via email to

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