4

I want to report a solution to an error I got while installing OpenFOAM 3.0.1 in Mac OS X El Capitan Version 10.11.2 The error was:

"error: member reference type 'std::istream *' (aka 'basic_istream *') is a pointer; maybe you meant to use '->'? yyin.rdbuf(std::cin.rdbuf());"

This problem is related to flex version 2.6.0. which I installed using macports.

I could overcome the problem by using "flex 2.5.35 Apple(flex-31)" which is at /usr/bin/flex (instead of /opt/local/flex).

Just change "flex" to "/usr/bin/flex" in the file $(WM_DIR)/rules/General/flex++ of your openfoam source distribution.

Brian
  • 3,850
  • 3
  • 21
  • 37
  • I don't know anything about this version of flex but it seems `yyin` is a pointer. Try to use `yyin->rdbuf(std::cin.rdbuf());`. – Dietmar Kühl Dec 23 '15 at 14:57
  • On stackoverflow, [answering its own question is encouraged](http://stackoverflow.com/help/self-answer), [as long as you pretend you’re on Jeopardy!](http://blog.stackoverflow.com/2011/07/its-ok-to-ask-and-answer-your-own-questions/) -- phrase it in the form of a question. – YSC Dec 23 '15 at 15:05
  • 1
    Really, it would be more effective to [report an OpenFOAM bug directly](http://www.openfoam.org/bugs/); which might help get the problem fixed. It's possible that this question might help some potential openfoam user who is able to search StackOverflow for their problem, but there are probably many potential users who would miss it. – rici Dec 23 '15 at 17:11
  • Thank you very much, this helped! (not for OpenFOAM btw. I had trouble with a completely unrelated package) – Ctx Dec 04 '16 at 15:38
  • installing OpenFOAM-7 same issues, solved by using 2.5.xx flex. – ArtificiallyIntelligence Aug 06 '19 at 02:00

2 Answers2

3

I think this might be a bit of a late answer, but I believe the issue is an out of sync "FlexLexer.h". Flex 2.6.0 changed the storage definition of yyin storage for C++ scanners for both the header and the generated source. However I suppose the mac port package is including an out-of-date FlexLexer.h, even though flex itself has been updated. This leads to the mismatch you are seeing as compilation errors.

Instead of downgrading your flex install, you might be able to just use a newer "FlexLexer.h" (for example the one from here: https://github.com/westes/flex/blob/master/src/FlexLexer.h)

Alex H.
  • 31
  • 3
1

I just compiled OpenFOAM v6 from the source code and got the same error - so this issue is still relevant. The error arised in wmake surfmesh where the first error was something like this

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());

The solution provided by changing flex to /usr/bin/flex in $HOME/OpenFOAM/OpenFOAM-6/wmake/rules/General/flex++ worked out for me.

Kalle Richter
  • 8,008
  • 26
  • 77
  • 177