c++ version hundreds of "needs to have dll interface" warning in visual studio 2015

1,464 views
Skip to first unread message

Joshua Scholar

unread,
Mar 27, 2017, 2:43:02 PM3/27/17
to antlr-discussion
I managed to get a grammar written for the C++ target (it compiles I haven't tried to use it yet - I haven't figured out how).

I get hundreds or thousands of warnings of the sort:

\antlr4-cpp-runtime-vs2015\antlr4-runtime\atn\arraypredictioncontext.h(23): warning C4251: 'antlr4::atn::ArrayPredictionContext::parents': class 'std::vector<std::shared_ptr<antlr4::atn::PredictionContext>,std::allocator<_Kty>>' needs to have dll-interface to be used by clients of class 'antlr4::atn::ArrayPredictionContext'

By the way, i dealt with not knowing how to use the listener/visitor classes by using grammar actions to build my own tree, which is the sort of tree I wanted in the first place.

Mike Lischke

unread,
Mar 28, 2017, 3:22:05 AM3/28/17
to antlr-di...@googlegroups.com

> I get hundreds or thousands of warnings of the sort:
>
> \antlr4-cpp-runtime-vs2015\antlr4-runtime\atn\arraypredictioncontext.h(23): warning C4251: 'antlr4::atn::ArrayPredictionContext::parents': class 'std::vector<std::shared_ptr<antlr4::atn::PredictionContext>,std::allocator<_Kty>>' needs to have dll-interface to be used by clients of class 'antlr4::atn::ArrayPredictionContext'


You shouldn't get those warnings, since C4251 is suppressed in the antlr4-runtime.h header (which is the only header you should include). This warning is about the well known problem that you shouldn't export templated classes or functions unless both the DLL as well as the DLL user have been built against the same C++ runtime. This is why there are prebuilt libraries for VS 2013 and VS2015 and not just one set.

Mike
--
www.soft-gems.net

Reply all
Reply to author
Forward
0 new messages