title: Moving code with struct usage from C to C++
body: <p>I have problems moving code that uses struct data from C to a C++ class.
  This struct <code>thread</code> is declared and an array of 3 elements is initialized.</p>
  
  <pre><code>static struct thread {
      const char *const filename;
      size_t buf_size;
  
      ssize_t (*in)(struct thread *, void *, size_t);
      const char *const in_name;
  
      ssize_t (*out)(struct thread *, const void *, size_t);
      const char *const out_name;
  
      int fd;
      pthread_t id;
      void *buf;
      ssize_t status;
  } threads[] = {
      {
          "ep0", 4 * sizeof(struct usb_functionfs_event),
              read_wrap, NULL,
              ep0_consume, "&lt;consume&gt;",
              0, 0, NULL, 0
      },
      {
          "ep1", 8 * 1024,
              fill_in_buf, "&lt;in&gt;",
              write_wrap, NULL,
              0, 0, NULL, 0
          },
          {
           "ep2", 8 * 1024,
              read_wrap, NULL,
              empty_out_buf, "&lt;out&gt;",
              0, 0, NULL, 0
          },
  };
  </code></pre>
  
  <p>Now I am declaring the struct in the header file outside my class like this:</p>
  
  <pre><code>struct stThread{
      const char *const filename;
      size_t buf_size;
      size_t (*in)(struct stThread *, void *, size_t);
      const char *const in_name;
      size_t (*out)(struct stThread *, const void *, size_t);
      const char *const out_name;
      int fd;
      pthread_t id;
      void *buf;
      size_t  status;
  };
  </code></pre>
  
  <p>and as a private member of my class I create an array of 3 elements of this <code>struct</code>:</p>
  
  <pre><code>struct stThread threads[3];
  </code></pre>
  
  <p>When I compile I get these errors:</p>
  
  <pre><code> In constructor "MyClass::MyClass(MyClass::UsbDescription*, void*)":
  /MyClass.cpp:76:65: error: uninitialized const member in "struct stThread"
  In file included from RDEmbeddedTools/FunctionFS.cpp:2:0:
  MyClass.hpp:78:20: note: "stThread::filename" should be initialized
  MyClass.cpp:76:65: error: uninitialized const member in "struct stThread"
  </code></pre>
  
  <p>What's wrong with my code here?
  Also, how can I assign values to the 3 elements of the array <code>threads</code> in the constructor?
  Is there a more comfortable way than this: </p>
  
  <pre><code>threads[0].filename = "foo";
  threads[0].buf_size = 1024;
  ...
  </code></pre>