title: Parsing struct with arrays with Boost Spirit
body: <p>Before I start, yes I know there are a lot of post related to this topic, I spend more than a day reading but my knowledge about Boost::spirit is limited so I can figure out how solve my problem.</p>
  
  <p>I take the Boost Employee example and modify it, let me show you</p>
  
  <pre><code>#include &lt;boost/config/warning_disable.hpp&gt;
  #include &lt;boost/spirit/include/qi.hpp&gt;
  #include &lt;boost/spirit/include/phoenix_core.hpp&gt;
  #include &lt;boost/spirit/include/phoenix_operator.hpp&gt;
  #include &lt;boost/spirit/include/phoenix_object.hpp&gt;
  #include &lt;boost/fusion/include/adapt_struct.hpp&gt;
  #include &lt;boost/fusion/include/io.hpp&gt;
  
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;complex&gt;
  
  namespace client
  {
      namespace qi = boost::spirit::qi;
      namespace ascii = boost::spirit::ascii;
  
      ///////////////////////////////////////////////////////////////////////////
      //  Our employee struct
      ///////////////////////////////////////////////////////////////////////////
      //[tutorial_employee_struct
  struct employee
  {
      char user[31];
      char pass[34];
      uint16_t page;        // Pagina de usuarios
      uint16_t port;        // Puerto por donde es realiza la comunicación
      uint8_t  ip[4];       // Direccion del socket de juego
      uint16_t amount;
      uint16_t cents;
      char nick[9];
      uint8_t already_logged;
      uint8_t version;
      uint8_t extension;
  };
  }
  
  // We need to tell fusion about our employee struct
  // to make it a first-class fusion citizen. This has to
  // be in global scope.
  
  //[tutorial_employee_adapt_struct
  BOOST_FUSION_ADAPT_STRUCT(
      client::employee,
      (char, user[31])
      (char, pass[34])
      (uint16_t, page)
      (uint16_t, port)
      (uint8_t, ip[4])
      (uint16_t, amount)
      (uint16_t, cents)
      (char, nick[9])
      (uint8_t, already_logged)
      (uint8_t, version)
      (uint8_t, extension)
  )
  //]
  
  namespace client
  {
      ///////////////////////////////////////////////////////////////////////////////
      //  Our employee parser
      ///////////////////////////////////////////////////////////////////////////////
      //[tutorial_employee_parser
      template &lt;typename Iterator&gt;
      struct employee_parser : qi::grammar&lt;Iterator, employee(), ascii::space_type&gt;
      {
          employee_parser() : employee_parser::base_type(start)
          {
              using boost::spirit::qi::ushort_;
              using ascii::char_;
  
              start %=
                  char_ &gt;&gt; ','
                  &gt;&gt; char_ &gt;&gt; ','
                  &gt;&gt; ushort_ &gt;&gt; ','
  
                  ;
          }
  
          qi::rule&lt;Iterator, employee(), ascii::space_type&gt; start;
      };
      //]
  }
  
  ////////////////////////////////////////////////////////////////////////////
  //  Main program
  ////////////////////////////////////////////////////////////////////////////
  int
  main()
  {
      std::cout &lt;&lt; "/////////////////////////////////////////////////////////\n\n";
      std::cout &lt;&lt; "\t\tAn employee parser for Spirit...\n\n";
      std::cout &lt;&lt; "/////////////////////////////////////////////////////////\n\n";
  
      std::cout
          &lt;&lt; "Give me an employee of the form :"
          &lt;&lt; "employee{age, \"surname\", \"forename\", salary } \n";
      std::cout &lt;&lt; "Type [q or Q] to quit\n\n";
  
      using boost::spirit::ascii::space;
      typedef std::string::const_iterator iterator_type;
      typedef client::employee_parser&lt;iterator_type&gt; employee_parser;
  
      employee_parser g; // Our grammar
      std::string str;
      while (getline(std::cin, str))
      {
          if (str.empty() || str[0] == 'q' || str[0] == 'Q')
              break;
  
          client::employee emp;
          std::string::const_iterator iter = str.begin();
          std::string::const_iterator end = str.end();
          bool r = phrase_parse(iter, end, g, space, emp);
  
          if (r &amp;&amp; iter == end)
          {
              std::cout &lt;&lt; boost::fusion::tuple_open('[');
              std::cout &lt;&lt; boost::fusion::tuple_close(']');
              std::cout &lt;&lt; boost::fusion::tuple_delimiter(", ");
  
              std::cout &lt;&lt; "-------------------------\n";
              std::cout &lt;&lt; "Parsing succeeded\n";
              std::cout &lt;&lt; "got: " &lt;&lt; boost::fusion::as_vector(emp) &lt;&lt; std::endl;
              std::cout &lt;&lt; "\n-------------------------\n";
          }
          else
          {
              std::cout &lt;&lt; "-------------------------\n";
              std::cout &lt;&lt; "Parsing failed\n";
              std::cout &lt;&lt; "-------------------------\n";
          }
      }
  
      std::cout &lt;&lt; "Bye... :-) \n\n";
      return 0;
  }
  </code></pre>
  
  <p>But I get this compilation errors and I have no idea how to solve it or how to write the parser </p>
  
  <pre><code>In file included from /usr/include/boost/fusion/include/as_vector.hpp:11:0,
                   from /usr/include/boost/spirit/home/support/attributes.hpp:24,
                   from /usr/include/boost/spirit/home/qi/detail/attributes.hpp:12,
                   from /usr/include/boost/spirit/home/qi/action/action.hpp:16,
                   from /usr/include/boost/spirit/home/qi/action.hpp:14,
                   from /usr/include/boost/spirit/home/qi.hpp:14,
                   from /usr/include/boost/spirit/include/qi.hpp:16,
                   from user.cpp:17:
  /usr/include/boost/fusion/container/vector/convert.hpp: In instantiation of ‘struct boost::fusion::result_of::as_vector&lt;const client::employee&gt;’:
  /usr/include/boost/fusion/container/vector/convert.hpp:43:5:   required by substitution of ‘template&lt;class Sequence&gt; typename boost::fusion::result_of::as_vector&lt;const Sequence&gt;::type boost::fusion::as_vector(const Sequence&amp;) [with Sequence = client::employee]’
  user.cpp:140:65:   required from here
  /usr/include/boost/fusion/container/vector/convert.hpp:27:13: error: invalid use of incomplete type ‘struct boost::fusion::detail::as_vector&lt;11&gt;’
               type;
               ^
  In file included from /usr/include/boost/fusion/container/vector/convert.hpp:11:0,
                   from /usr/include/boost/fusion/include/as_vector.hpp:11,
                   from /usr/include/boost/spirit/home/support/attributes.hpp:24,
                   from /usr/include/boost/spirit/home/qi/detail/attributes.hpp:12,
                   from /usr/include/boost/spirit/home/qi/action/action.hpp:16,
                   from /usr/include/boost/spirit/home/qi/action.hpp:14,
                   from /usr/include/boost/spirit/home/qi.hpp:14,
                   from /usr/include/boost/spirit/include/qi.hpp:16,
                   from user.cpp:17:
  /usr/include/boost/fusion/container/vector/detail/as_vector.hpp:26:12: error: declaration of ‘struct boost::fusion::detail::as_vector&lt;11&gt;’
       struct as_vector;
              ^
  In file included from /usr/include/boost/fusion/include/as_vector.hpp:11:0,
                   from /usr/include/boost/spirit/home/support/attributes.hpp:24,
                   from /usr/include/boost/spirit/home/qi/detail/attributes.hpp:12,
                   from /usr/include/boost/spirit/home/qi/action/action.hpp:16,
                   from /usr/include/boost/spirit/home/qi/action.hpp:14,
                   from /usr/include/boost/spirit/home/qi.hpp:14,
                   from /usr/include/boost/spirit/include/qi.hpp:16,
                   from user.cpp:17:
  /usr/include/boost/fusion/container/vector/convert.hpp: In instantiation of ‘struct boost::fusion::result_of::as_vector&lt;client::employee&gt;’:
  /usr/include/boost/fusion/container/vector/convert.hpp:34:5:   required by substitution of ‘template&lt;class Sequence&gt; typename boost::fusion::result_of::as_vector&lt;Sequence&gt;::type boost::fusion::as_vector(Sequence&amp;) [with Sequence = client::employee]’
  user.cpp:140:65:   required from here
  /usr/include/boost/fusion/container/vector/convert.hpp:27:13: error: invalid use of incomplete type ‘struct boost::fusion::detail::as_vector&lt;11&gt;’
               type;
               ^
  In file included from /usr/include/boost/fusion/container/vector/convert.hpp:11:0,
                   from /usr/include/boost/fusion/include/as_vector.hpp:11,
                   from /usr/include/boost/spirit/home/support/attributes.hpp:24,
                   from /usr/include/boost/spirit/home/qi/detail/attributes.hpp:12,
                   from /usr/include/boost/spirit/home/qi/action/action.hpp:16,
                   from /usr/include/boost/spirit/home/qi/action.hpp:14,
                   from /usr/include/boost/spirit/home/qi.hpp:14,
                   from /usr/include/boost/spirit/include/qi.hpp:16,
                   from user.cpp:17:
  /usr/include/boost/fusion/container/vector/detail/as_vector.hpp:26:12: error: declaration of ‘struct boost::fusion::detail::as_vector&lt;11&gt;’
       struct as_vector;
              ^
  user.cpp: In function ‘int main()’:
  user.cpp:140:65: error: no matching function for call to ‘as_vector(client::employee&amp;)’
               std::cout &lt;&lt; "got: " &lt;&lt; boost::fusion::as_vector(emp) &lt;&lt; std::endl;
                                                                   ^
  user.cpp:140:65: note: candidates are:
  In file included from /usr/include/boost/fusion/include/as_vector.hpp:11:0,
                   from /usr/include/boost/spirit/home/support/attributes.hpp:24,
                   from /usr/include/boost/spirit/home/qi/detail/attributes.hpp:12,
                   from /usr/include/boost/spirit/home/qi/action/action.hpp:16,
                   from /usr/include/boost/spirit/home/qi/action.hpp:14,
                   from /usr/include/boost/spirit/home/qi.hpp:14,
                   from /usr/include/boost/spirit/include/qi.hpp:16,
                   from user.cpp:17:
  /usr/include/boost/fusion/container/vector/convert.hpp:34:5: note: template&lt;class Sequence&gt; typename boost::fusion::result_of::as_vector&lt;Sequence&gt;::type boost::fusion::as_vector(Sequence&amp;)
       as_vector(Sequence&amp; seq)
       ^
  /usr/include/boost/fusion/container/vector/convert.hpp:34:5: note:   substitution of deduced template arguments resulted in errors seen above
  /usr/include/boost/fusion/container/vector/convert.hpp:43:5: note: template&lt;class Sequence&gt; typename boost::fusion::result_of::as_vector&lt;const Sequence&gt;::type boost::fusion::as_vector(const Sequence&amp;)
       as_vector(Sequence const&amp; seq)
       ^
  /usr/include/boost/fusion/container/vector/convert.hpp:43:5: note:   substitution of deduced template arguments resulted in errors seen above
  </code></pre>
  
  <p>My only need is to have a fixed size struct, that is the reason to use char XXX[31], but I can change this for any declaration with a fixed size.</p>
  
  <p>Thank you in advance</p>