google-signin-unity icon indicating copy to clipboard operation
google-signin-unity copied to clipboard

Initialization of google::signin::GoogleSignIn::Configuration fails to compile under C++20 due to P1008

Open solodon4 opened this issue 4 years ago • 0 comments

Initialization of google::signin::GoogleSignIn::Configuration as described in Integrate Play Games sign-in into your game via any of the following syntaxes:

Configuration config{};
Configuration config = {};
Configuration config = Configuration();

fails with:

error: no matching constructor for initialization of 'google::signin::GoogleSignIn::Configuration

when done from a project built with C++20, essentially leaving developers that depend on C++20 features with no means of initializing that struct anyhow. This happens due to changes in C++20 that were brought by P1008 as explained in details in Why does aggregate initialization not work anymore since C++20 if a constructor is explicitly defaulted or deleted?.

Here is a relevant extract of the source from google_signing.h:90-122 on Compiler Explorer: https://godbolt.org/z/fdqoE5YqG that demonstrates the issue under Clang 9 used by recent Android NDK. As soon as you change the standard to -std=c++17, the code compiles.

To fix the issue, just get rid of defaulted and deleted constructors and assignments:

  //Configuration(Configuration const &copy) = default;
  //Configuration(Configuration &&move) = delete;
    ~Configuration() = default;

  //Configuration &operator=(Configuration const &copy) = delete;
  //Configuration &operator=(Configuration &&move) = delete;

solodon4 avatar Sep 06 '21 00:09 solodon4