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
  • 698,132
  • 130
  • 858
  • 1,229
Sohail Si
  • 2,376
  • 2
  • 20
  • 33

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
  • 72,003
  • 32
  • 177
  • 319