0

My last c++ Project was about 3 years ago and know I have some problems with basics.

I have a class stuff. In my .h file i have a struct:

typedef struct
{
  float fX;
  float fY;
  float fZ;
  float fRx;
  float fRy;
  float fRz;
  char aName[14] = "";
} stpoint;

and a private variable stpoint _stpoints[].

In my.cpp I have a function:

void stuff::getstuff()
{
  stpoint _stpoints[] = {
    { 164.5, 0.0, 241.0, 90.0, 180.0, -90.0,"Home"},
    { 164.5, 0.0, 141.0, 90.0, 180.0, -90.0,"X1"},
    { 164.5 + 14.7, 35.4, 141.0, 90.0, 180.0, -90.0 ,"X11"},
    { 164.5 + 50.0, 50.0, 141.0, 90.0, 180.0, -90.0,"X12"},
    { 164.5 + 85.3, 35.4, 141.0, 90.0, 180.0, -90.0,"X13"},
    { 164.5 + 100.0, 0.0, 141.0, 90.0, 180.0, -90.0,"X14"},
    { 164.5 + 85.3, -35.4, 141.0, 90.0, 180.0, -90.0,"X15"},
    { 164.5 + 50.0, -50.0, 141.0, 90.0, 180.0, -90.0,"X16"},
    { 164.5 + 14.7, -35.4, 141.0, 90.0, 180.0, -90.0,"X17"},
    { 164.5 + 50.0, 0.0, 141.0, 90.0, 180.0, -90.0,"X18"},
    { 264.5, 0.0, 141.0, 0.0, 90.0, 0.0 ,"X2"},
    { 164.5, 100.0, 141.0, 90.0, 90.0, 0.0,"X3"},
    { 164.5, -100.0, 141.0, 90.0, -90.0, 0.0,"X4"}
  };
}

Its a project for Arduino. I use VS2019.

I get error code (just one of them):

stuff.cpp: 37:2: error: could not convert '{1.645e+2, 0.0, 2.41e+2, 9.0e+1, 1.8e+2, -9.0e+1, "Home"}' from '' to 'stuff::stpoint
Error compiling project sources
Debug build failed for project 'Roboter'

It something about the char array in the struct but i dont get it :(

struct stpoint _stpoints2 = { 164.5, 0.0, 241.0, 90.0, 180.0, -90.0,"Home"} gives the same error.

3
  • Please produce a minimal example that demonstrate the problem. Your typedef is stpoint from the error message is about stuff::stpoint. gcc complains about the the "" default value and seem happier with {""}. Also see stackoverflow.com/questions/24741237/… Commented Dec 28, 2020 at 1:17
  • 1
    stackoverflow.com/questions/11643844/… might be relevant too. Commented Dec 28, 2020 at 1:23
  • hey that solved my problem thanks Commented Dec 28, 2020 at 13:17

2 Answers 2

0

@πάντα ῥεῖ

 typedef struct
 {
     float fX;
     float fY;
     float fZ;
     float fRx;
     float fRy;
     float fRz;
     char aName[14];
 } stpoint;

that solved the problem. thanks

Sign up to request clarification or add additional context in comments.

Comments

0

Initialize with aName = { "" }.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.