2

How can I verify whether a function is expanded inline in a C++ program? My Compiler is Emscripten but an answer for g++ probably works.

Ideally, a code that runs differently when in inline mode (although it should not have any side effects).

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
Sohail Si
  • 2,750
  • 2
  • 22
  • 36

1 Answers1

6

You can enable the -Winline warning which prints a warning when a function marked inline wasn't inlined.

See the documentation.

As an alternative, you can mark the function always_inline which will trigger an error if it wasn't inlined. See the documentation.

rubenvb
  • 74,642
  • 33
  • 187
  • 332