I’m trying to use Flex with Visual C++. However, the generated lexer (which is empty and has no rules) throws these errors while building:
configurationlexer.cpp(967): error C3861: 'read' identifier not found
configurationlexer.cpp(967): fatal error C1903: unable to recover from previous error(s); stopping compilation
The source file is:
%{
#include <string>
%}
%option yylineno
%%
%%
//Lexer End
I’m building by adding this target to my Visual Studio project:
<Target Name="Flex" Inputs="$(MSBuildProjectDirectory)\ConfigurationLexer.l" Outputs="$(MSBuildProjectDirectory)\ConfigurationLexer.cpp;$(MSBuildProjectDirectory)\ConfigurationLexer.hpp">
<Exec Command="C:\Cygwin\bin\flex.exe --nounistd -f -o "$(MSBuildProjectDirectory)\ConfigurationLexer.cpp" "--header=$(MSBuildProjectDirectory)\ConfigurationLexer.hpp" "$(MSBuildProjectDirectory)\ConfigurationLexer.l"" />
</Target>
Is it possible to use Flex with MSVC?
Well, it would be helpful if the bozo that is Bill would read the documentation:
which leads to:
I turned off -F and now everything works as expected. For other reasons, I had to turn on –never-interactive. –always-interactive also works if you want an interactive scanner …. I don’t.