1

Clang header file intrin.h declares the _BitScanForward as below.

static
unsigned char _BitScanForward(unsigned long *_Index, unsigned long _Mask);

When I include this header file and compile the source file, it is giving compilation error like below

error: inline function '_BitScanForward' is not defined [-Werror,-Wundefined-inline]
_BitScanForward (

This is happening only in our code base but I am unable to reproduce this compilation error outside our environment.

Could somebody please explain what is this "-Wundefined-inline" mean?

Why is the question of "inline" coming into picture?

More Info: When put inline keyword just after static, its compiling without any issues

Pendyala
  • 585
  • 1
  • 6
  • 17
  • 1
    Does this answer your question? [undefined reference when calling inline function](https://stackoverflow.com/questions/19068705/undefined-reference-when-calling-inline-function) – Gene Z. Ragan Nov 07 '19 at 19:13
  • This is a C question, not a C++ question. If this was a C++ function, then _BitscanForward would surely have been declared as `constexpr` instead of `static` or `static inline`. But question and answers would still be the same. One thing to note though. C++ compilers (at least my current compiler clang-12) may print this error also, if you have overloads that do not agree on the same qualifications. I.e. all overloads must be constexpr or all must be not. I don't know if this is mandated by the standard, I believe not. Maybe a language lawyer can clarify. – Patrick Fromberg Aug 03 '22 at 04:59

1 Answers1

3

It is the compiler telling you which error flag(s) triggered the specific warning. There are many different warning flags you can enable in the compiler so reporting which flag triggered the warning can be helpful.

NathanOliver
  • 171,901
  • 28
  • 288
  • 402
  • But could you please tell me why its saying function _BitScanForward is inline? – Pendyala Nov 07 '19 at 19:29
  • 1
    @Pendyala Without a [mre] I can't say. – NathanOliver Nov 07 '19 at 19:30
  • Actually I am unable to reproduce this issue outside my environment. So I have no clue when this kind of issue happens, and what is the cause. – Pendyala Nov 07 '19 at 19:31
  • @Pendyala Looking into it more, [this](https://stackoverflow.com/questions/26105525/why-can-i-not-inline-a-function-in-my-class) should answer your question on why the warning is being generated. You can suppress it using `-Wno-undefined-inline` – NathanOliver Nov 07 '19 at 19:39
  • Thanks Nathan, Here _BitScanForward is not declared as inline function. But why compiler is saying it is inline and has to be defined? – Pendyala Nov 07 '19 at 19:49
  • @Pendyala Per [this](https://github.com/llvm-mirror/clang/blob/master/lib/Headers/intrin.h#L146) it is – NathanOliver Nov 07 '19 at 19:53
  • ah... seems I have messed up things locally. I will recheck them. Thanks Nathan. – Pendyala Nov 07 '19 at 19:59