openfoam: flex yyin.rdbuf(std::cin.rdbuf() error

openfoam: flex yyin.rdbuf(std::cin.rdbuf() error

本文关键字:rdbuf error cin std openfoam flex yyin      更新时间:2023-10-16

我想报告错误I的解决方案在Mac OS X El Capitan版本10.11.2中安装OpenFOAM 3.0.1时获得错误是:

"错误:成员引用类型"std::istream*"(又名"basic_istream*")是指针;也许你是想用"->"?yyin.rdbuf(std::cin.rdbuff());"

这个问题与flex version 2.6.0有关。我使用macports安装的。

我可以通过使用位于/usr/bin/flex(而不是/opt/local/flex)的"flex 2.5.35 Apple(flex-31)"来克服这个问题。

只需将文件中的"flex"更改为"/usr/bin/flex"$(WM_DIR)/规则/常规/flex++您的openfoam源代码分发。

我认为这可能是一个有点晚的答案,但我认为问题是"FlexLexer.h"不同步。Flex 2.6.0为C++扫描程序更改了yyin存储的存储定义,用于头和生成的源。然而,我认为mac端口包包括一个过时的FlexLexer.h,尽管flex本身已经更新。这会导致您将不匹配视为编译错误。

您可以使用更新的"FlexLexer.h"(例如,下面的版本:https://github.com/westes/flex/blob/master/src/FlexLexer.h)

我刚刚从源代码编译了OpenFOAM v6,并得到了相同的错误,所以这个问题仍然相关。错误出现在wmake surfmesh中,其中第一个错误类似于

flex -+ ..........  
.../OpenFOAM/OpenFOAM- 6/platforms/linux64GccDPInt32Opt/src/surfMesh/surfaceFormats/stl/STLsurfaceFormatASCII.L.C: In member function ‘int STLASCIILexer::lex()’:  
.../OpenFOAM/OpenFOAM-6/platforms/linux64GccDPInt32Opt/src/surfMesh/surfaceFormats/stl/STLsurfaceFormatASCII.L.C:5494:9: error: request for member ‘rdbuf’ in ‘((STLASCIILexer*)this)->STLASCIILexer::<anonymous>.yyFlexLexer::yyin’, which is of pointer type ‘std::istream* {aka std::basic_istream<char>*}’ (maybe you meant to use ‘->’ ?)
yyin.rdbuf(std::cin.rdbuf());

$HOME/OpenFOAM/OpenFOAM-6/wmake/rules/General/flex++中的flex更改为/usr/bin/flex所提供的解决方案对我来说是可行的。

相关文章: