英文:
Compilation of derived class from boost::spirit::qi::grammar failed with __declspec( dllexport )
问题
I am trying to implement a class that inherits from boost::spirit::qi::grammar and make it exportable in dynamic library:
#pragma once
#include <impexp.h>
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix.hpp>
using boost::spirit::ascii::space_type;
struct EXPORT_DLLCLASS Grammar : boost::spirit::qi::grammar<char const*, space_type>
{
Grammar()
: Grammar::base_type( expr )
{
}
boost::spirit::qi::rule<char const*, space_type> expr, term;
};
I'm using EXPORT_DLLCLASS
to specify __attribute__( ( visibility( "default" ) ) )
or __declspec( dllexport )
depending on the platform. Build succeeds under Linux platform, but I have problems with compilation under Windows platform with the following errors:
C:\.conan\oq2odq\1\include\boost/proto/extends.hpp(536,17): error: call to implicitly-deleted default constructor of 'boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<boost::spirit::qi::reference<const boost::spirit::qi::rule<const char *, boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<boost::spirit::tag::char_code<boost::spirit::tag::space, boost::spirit::char_encoding::ascii> >, 0>, boost::spirit::unused_type, boost::spirit::unused_type, boost::spirit::unused_type> > >, 0>'
: proto_expr_()
^
C:\.conan\oq2odq\1\include\boost/proto/proto_fwd.hpp(377,16): note: in instantiation of member function 'boost::proto::exprns_::extends<boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<boost::spirit::qi::reference<const boost::spirit::qi::rule<const char *, boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<boost::spirit::tag::char_code<boost::spirit::tag::space, boost::spirit::char_encoding::ascii> >, 0>, boost::spirit::unused_type, boost::spirit::unused_type, boost::spirit::unused_type> > >, 0>, boost::spirit::qi::grammar<const char *, boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<boost::spirit::tag::char_code<boost::spirit::tag::space, boost::spirit::char_encoding::ascii> >, 0>, boost::spirit::unused_type, boost::spirit::unused_type, boost::spirit::unused_type>, boost::proto::domainns_::default_domain, 0>::extends' requested here
struct extends;
^
C:\.conan\oq2odq\1\include\boost/proto/detail/preprocessed/expr_variadic.hpp(50,49): note: default constructor of 'expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<boost::spirit::qi::reference<const boost::spirit::qi::rule<const char *, boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<boost::spirit::tag::char_code<boost::spirit::tag::space, boost::spirit::char_encoding::ascii> >, 0>, boost::spirit::unused_type, boost::spirit::unused_type, boost::spirit::unused_type> > >, 0>' is implicitly deleted because field 'child0' has no default constructor
typedef Arg0 proto_child0; proto_child0 child0;
Build succeeds if EXPORT_DLLCLASS
is not specified. Any ideas?
英文:
I am trying to implement a class that inherits from boost::spirit::qi::grammar and make it exportable in dynamic library:
#pragma once
#include <impexp.h>
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix.hpp>
using boost::spirit::ascii::space_type;
struct EXPORT_DLLCLASS Grammar : boost::spirit::qi::grammar< char const*, space_type >
{
Grammar()
: Grammar::base_type( expr )
{
}
boost::spirit::qi::rule< char const*, space_type > expr, term;
};
I'm using EXPORT_DLLCLASS
to specify __attribute__( ( visibility( "default" ) ) )
or __declspec( dllexport )
depending on the platform. Build succeeds under Linux platform, but I have problems with compilation under Windows platform with the following errors:
C:\.conan\oq2odq\1\include\boost/proto/extends.hpp(536,17): error: call to implicitly-deleted default constructor of 'boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<boost::spirit::qi::reference<const boost::spirit::qi::rule<const char *, boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<boost::spirit::tag::char_code<boost::spirit::tag::space, boost::spirit::char_encoding::ascii> >, 0>, boost::spirit::unused_type, boost::spirit::unused_type, boost::spirit::unused_type> > >, 0>'
: proto_expr_()
^
C:\.conan\oq2odq\1\include\boost/proto/proto_fwd.hpp(377,16): note: in instantiation of member function 'boost::proto::exprns_::extends<boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<boost::spirit::qi::reference<const boost::spirit::qi::rule<const char *, boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<boost::spirit::tag::char_code<boost::spirit::tag::space, boost::spirit::char_encoding::ascii> >, 0>, boost::spirit::unused_type, boost::spirit::unused_type, boost::spirit::unused_type> > >, 0>, boost::spirit::qi::grammar<const char *, boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<boost::spirit::tag::char_code<boost::spirit::tag::space, boost::spirit::char_encoding::ascii> >, 0>, boost::spirit::unused_type, boost::spirit::unused_type, boost::spirit::unused_type>, boost::proto::domainns_::default_domain, 0>::extends' requested here
struct extends;
^
C:\.conan\oq2odq\1\include\boost/proto/detail/preprocessed/expr_variadic.hpp(50,49): note: default constructor of 'expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<boost::spirit::qi::reference<const boost::spirit::qi::rule<const char *, boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<boost::spirit::tag::char_code<boost::spirit::tag::space, boost::spirit::char_encoding::ascii> >, 0>, boost::spirit::unused_type, boost::spirit::unused_type, boost::spirit::unused_type> > >, 0>' is implicitly deleted because field 'child0' has no default constructor
typedef Arg0 proto_child0; proto_child0 child0;
Build succeeds if EXPORT_DLLCLASS
is not specified.
Any ideas?
答案1
得分: 2
确认,与 MSVC 19.34.31931 x64 (以及 GCC) 并排查看(尽管在 https://compiler-explorer.com/z/o67TYxdnf 上有略有不同的诊断):
C:/data/libraries/installed/x64-windows/include\boost/proto/extends.hpp(558):错误 C2440:'return':无法将类型从 'T *' 转换为 'boost::proto::detail::not_a_valid_type'
其中
[
T=const boost::spirit::qi::reference<const boost::spirit::qi::rule<const char *,boost::spirit::ascii::space_type,boost::spirit::unused_type,boost::spirit::unused_type,boost::spirit::unused_type>>
]
C:/data/libraries/installed/x64-windows/include\boost/proto/extends.hpp(558):注意:无法使用源类型执行构造函数,或构造函数重载分辨模糊
C:/data/libraries/installed/x64-windows/include\boost/proto/extends.hpp(558):注意:在编译类模板成员函数 'boost::proto::exprns_::extends<boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal,boost::proto::argsns_::term
其中
[
T=boost::spirit::qi::reference<const boost::spirit::qi::rule<const char *,boost::spirit::ascii::space_type,boost::spirit::unused_type,boost::spirit::unused_type,boost::spirit::unused_type>>
]
C:/data/libraries/installed/x64-windows/include\boost/spirit/home/qi/nonterminal/grammar.hpp(32):注意:请参考正在编译的类模板实例化 'boost::proto::exprns_::extends<boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal,boost::proto::argsns_::term
其中
[
T=boost::spirit::qi::reference<const boost::spirit::qi::rule<const char *,boost::spirit::ascii::space_type,boost::spirit::unused_type,boost::spirit::unused_type,boost::spirit::unused_type>>
]
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论