Hey,

I have a use-case for inline variables, and it's not 100% clear to me
how up-to-date is [1], so asking this mailing-list directly.

Looks like they're supported from clang 3.9 [2] and gcc 7 [3].

We're requiring clang 4.0+ to build already, and IIUC we don't build
with MSVC anymore. But looks like we still support gcc 6 (which I guess
means I can't use them right now).

Is that right? If so, how far are we from requiring gcc 7 to build?

In case you're curious, my use case is generating idiomatic bindings for
Rust associated constants (and bitflags in particular)[4]. Ideally, you
should be able to translate the following Rust code:

struct Bitflags {
  bits: u8,
}

impl Bitflags {
  const FOO: Bitflags = Bitflags { bits: 0 };
}

Into the following C++:

struct Bitflags {
  uint8_t bits;

  constexpr static const Bitflags FOO = {0};
};

But that doesn't work, since the `Bitflags` type is not complete by the
time you declare FOO. Inline variables allow to solve this without
sacrificing performance or making code less idiomatic.

 -- Emilio

[1]:
https://developer.mozilla.org/en-US/docs/Mozilla/Using_CXX_in_Mozilla_code
[2]: https://clang.llvm.org/cxx_status.html
[3]: https://gcc.gnu.org/projects/cxx-status.html
[4]: https://github.com/eqrion/cbindgen/pull/293
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to