1

I use link-time optimization (-flto in g++ and ld command lines) and some of my method declarations (in headers) are marked as extern inline (and just inline in .cpp files). Compiling yields:

./Client/include/GVGLObjects.hpp:96:32: error: storage class specified for 'VertexBuffer'
             EFAST VertexBuffer();
                                ^

and a bunch of similar errors for other methods and functions. EFAST means extern inline.

Why is this happening with LTO enabled? If this isn't allowed, how do I separate declaration and definition with inline and LTO?

L. F.
  • 19,445
  • 8
  • 48
  • 82
Kotauskas
  • 1,239
  • 11
  • 31

1 Answers1

1

extern inline exists in C, not in C++, though many compilers permit it as an extension (ref).

Presumably whatever mechanism and file format GCC uses to perform LTO (ref) is not compatible with this non-standard thing. The documentation for -flive-patching=level is interesting, because it describes stuff relating to inlining and storage classes, and tells us that some of it is not available when using LTO (though the actual -flto description doesn't specifically call out the extern inline extension).

You probably do not want this EFAST macro in C++ code.

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
  • Unfortunately, replacing `EFAST` with `FAST` (`inline`) yields the same result. – Kotauskas Jul 26 '19 at 11:24
  • @VladislavToncharov That cannot be so. The shown error message only makes sense when a storage class is specified, which you now claim not to be doing. – Lightness Races in Orbit Jul 26 '19 at 12:17
  • Oh, my bad. Looked at the wrong log by accident; of course it doesn't. Instead it just says "inline function used but never defined", and the linker throws "undefined reference". – Kotauskas Jul 26 '19 at 12:21
  • @VladislavToncharov Then we're going to need a [mcve] but this is a new question. – Lightness Races in Orbit Jul 26 '19 at 12:22
  • [Here it is.](https://stackoverflow.com/questions/57220421/g-and-lto-how-to-separate-declaration-and-definition "G++ and LTO: how to separate declaration and definition?") – Kotauskas Jul 26 '19 at 12:49