c++ - Copy constructor for C volatile bitfield struct -


good day

i trying use c sd driver/file system libary (keil mdk), in c++11 project. added pack manager in keil mdk 5.23. compiling armcc 5.06u4

i warning class "_arm_mci_status" has no suitable copy constructor" odd, because header declared in has extern "c" {.

by default, pack has no option set c or c++, have manually added file c file. still problem.

the struct declared, within extern "c" { as:

typedef volatile struct _arm_mci_status {     uint32_t command_active   : 1;        ///< command active flag     uint32_t command_timeout  : 1;        ///< command timeout flag (cleared on start of next command)     uint32_t command_error    : 1;        ///< command error flag (cleared on start of next command)     uint32_t transfer_active  : 1;        ///< transfer active flag     uint32_t transfer_timeout : 1;        ///< transfer timeout flag (cleared on start of next command)     uint32_t transfer_error   : 1;        ///< transfer error flag (cleared on start of next command)     uint32_t sdio_interrupt   : 1;        ///< sd i/o interrupt flag (cleared on start of monitoring)     uint32_t ccs              : 1;        ///< ccs flag (cleared on start of next command)     uint32_t reserved         : 24; } arm_mci_status; 

the problem occurs when struct being returned at:

static arm_mci_status getstatus (mci_resources *mci) {   return mci->info->status; } 

where status declared arm_mci_status status;. don't see why should issue.

if compile without --cpp compiles without issue.

any suggestions?

just because struct marked extern "c" doesn't mean won't still compiled c++ code.

this means return mci->info->status; invokes implicitly generated copy constructor. because _arm_mci_status marked volatile, it's members are, means default copy constructor takes t& can't bind volatile lvalue reference it's passed.

this explained in cppreference explanation:

otherwise, implicitly-declared copy constructor t::t(t&). (note due these rules, implicitly-declared copy constructor cannot bind volatile lvalue argument.)

and in actual standard (just having hard time finding correct clause it's in there).


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -