cannot pass objects of non-trivially-copyable type 'struct

This is the error I get:

cannot pass objects of non-trivially-copyable type 'struct std::string' through '...'

for the code below:

##############################
#define MAX 64

string GPIOarray[] = {"GND", "POS"};


char setValue[4], GPIOString[4], GPIOValue[15], GPIODirection[MAX], GPIOMux[MAX];
int main(){
for (int n=0 ; n<1 ; n++ )
{
sprintf(GPIOMux, "/sys/kernel/debug/omap_mux/", GPIOarray[n]); // ERROR HERE
.
.
.
}
##################################
I am trying to get a final strings of:

/sys/kernel/debug/omap_mux/GND
/sys/kernel/debug/omap_mux/POS
Last edited on
You might need to use the .c_str() method for GPIOarray[n]

sprintf(GPIOMux, "/sys/kernel/debug/omap_mux/%s", GPIOarray[n].c_str());

http://www.cplusplus.com/reference/string/string/c_str/

EDIT: You also forgot to include "%s" in the format parameter.
Last edited on
Thanks Branflakes91093, that did the trick.
Topic archived. No new replies allowed.