tags 813951 + patch
thanks

On Sun, 7 Feb 2016, Mattia Rizzolo wrote:

> undefined reference to `yyFlexLexer::yywrap()'

This seems to be a problem with new flex behaviour.

Code written to work with "old" flex need this declaration:

extern "C" int yywrap()

and code written to work with "new" flex need this one:

int yyFlexLexer::yywrap()

The authors combined both things with a preprocessor conditional:

#if YY_FLEX_SUBMINOR_VERSION < 34
 extern "C" int yywrap()
#else
 int yyFlexLexer::yywrap()
#endif
  
but this assumes that flex is 2.5.x where x is YY_FLEX_SUBMINOR_VERSION.

If flex is 2.6.0, which is also the "new" flex, then 0 < 34 is true
and the wrong code is used.

I found the official fix in openfoam here:

http://bugs.openfoam.org/view.php?id=2066

which is to write the condition in this way:

#if YY_FLEX_MINOR_VERSION < 6 && YY_FLEX_SUBMINOR_VERSION < 34

The affected files are the following:

src/surfMesh/surfaceFormats/stl/STLsurfaceFormatASCII.L
src/triSurface/triSurface/interfaces/STL/readSTLASCII.L
src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinLexer.L
applications/utilities/mesh/conversion/fluentMeshToFoam/fluentMeshToFoam.L
applications/utilities/mesh/conversion/ansysToFoam/ansysToFoam.L
applications/utilities/mesh/conversion/fluent3DMeshToFoam/fluent3DMeshToFoam.L
applications/utilities/mesh/conversion/gambitToFoam/gambitToFoam.L

and the resulting patch is attached (warning: I have not actually
tested it, I have only explained why the patch is required :-).

Since this package is team-maintained, could somebody in the team
verify that the patch works and make an upload? I'd like this package
not to removed from Debian.

Thanks.
diff --git a/applications/utilities/mesh/conversion/ansysToFoam/ansysToFoam.L 
b/applications/utilities/mesh/conversion/ansysToFoam/ansysToFoam.L
index 947b069..ca6e7a8 100644
--- a/applications/utilities/mesh/conversion/ansysToFoam/ansysToFoam.L
+++ b/applications/utilities/mesh/conversion/ansysToFoam/ansysToFoam.L
@@ -95,7 +95,7 @@ label currentTypei = -1;
 // Dummy yywrap to keep yylex happy at compile time.
 // It is called by yylex but is not used as the mechanism to change file.
 // See <<EOF>>
-#if YY_FLEX_SUBMINOR_VERSION < 34
+#if YY_FLEX_MINOR_VERSION < 6 && YY_FLEX_SUBMINOR_VERSION < 34
 extern "C" int yywrap()
 #else
 int yyFlexLexer::yywrap()
diff --git 
a/applications/utilities/mesh/conversion/fluent3DMeshToFoam/fluent3DMeshToFoam.L
 
b/applications/utilities/mesh/conversion/fluent3DMeshToFoam/fluent3DMeshToFoam.L
index 99a4c6d..15c7a9b 100644
--- 
a/applications/utilities/mesh/conversion/fluent3DMeshToFoam/fluent3DMeshToFoam.L
+++ 
b/applications/utilities/mesh/conversion/fluent3DMeshToFoam/fluent3DMeshToFoam.L
@@ -147,7 +147,7 @@ void uniquify(word& name, HashSet<word>& patchNames)
 // Dummy yywrap to keep yylex happy at compile time.
 // It is called by yylex but is not used as the mechanism to change file.
 // See <<EOF>>
-#if YY_FLEX_SUBMINOR_VERSION < 34
+#if YY_FLEX_MINOR_VERSION < 6 && YY_FLEX_SUBMINOR_VERSION < 34
 extern "C" int yywrap()
 #else
 int yyFlexLexer::yywrap()
diff --git 
a/applications/utilities/mesh/conversion/fluentMeshToFoam/fluentMeshToFoam.L 
b/applications/utilities/mesh/conversion/fluentMeshToFoam/fluentMeshToFoam.L
index 32550da..c2b0f5f 100644
--- a/applications/utilities/mesh/conversion/fluentMeshToFoam/fluentMeshToFoam.L
+++ b/applications/utilities/mesh/conversion/fluentMeshToFoam/fluentMeshToFoam.L
@@ -126,7 +126,7 @@ wordList patchNameIDs(maxZoneID);
 // Dummy yywrap to keep yylex happy at compile time.
 // It is called by yylex but is not used as the mechanism to change file.
 // See <<EOF>>
-#if YY_FLEX_SUBMINOR_VERSION < 34
+#if YY_FLEX_MINOR_VERSION < 6 && YY_FLEX_SUBMINOR_VERSION < 34
 extern "C" int yywrap()
 #else
 int yyFlexLexer::yywrap()
diff --git a/applications/utilities/mesh/conversion/gambitToFoam/gambitToFoam.L 
b/applications/utilities/mesh/conversion/gambitToFoam/gambitToFoam.L
index 0df85b5..d2baa9e 100644
--- a/applications/utilities/mesh/conversion/gambitToFoam/gambitToFoam.L
+++ b/applications/utilities/mesh/conversion/gambitToFoam/gambitToFoam.L
@@ -99,7 +99,7 @@ label nValuesForPatchFaces = 0;
 // Dummy yywrap to keep yylex happy at compile time.
 // It is called by yylex but is not used as the mechanism to change file.
 // See <<EOF>>
-#if YY_FLEX_SUBMINOR_VERSION < 34
+#if YY_FLEX_MINOR_VERSION < 6 && YY_FLEX_SUBMINOR_VERSION < 34
 extern "C" int yywrap()
 #else
 int yyFlexLexer::yywrap()
diff --git a/src/surfMesh/surfaceFormats/stl/STLsurfaceFormatASCII.L 
b/src/surfMesh/surfaceFormats/stl/STLsurfaceFormatASCII.L
index c51b738..81283b8 100644
--- a/src/surfMesh/surfaceFormats/stl/STLsurfaceFormatASCII.L
+++ b/src/surfMesh/surfaceFormats/stl/STLsurfaceFormatASCII.L
@@ -50,7 +50,7 @@ int yyFlexLexer::yylex()
 // It is called by yylex but is not used as the mechanism to change file.
 // See <<EOF>>
 //! @cond dummy
-#if YY_FLEX_SUBMINOR_VERSION < 34
+#if YY_FLEX_MINOR_VERSION < 6 && YY_FLEX_SUBMINOR_VERSION < 34
 extern "C" int yywrap()
 #else
 int yyFlexLexer::yywrap()
diff --git 
a/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinLexer.L
 
b/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinLexer.L
index 863f4bb..1ceae20 100644
--- 
a/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinLexer.L
+++ 
b/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinLexer.L
@@ -54,7 +54,7 @@ int yyFlexLexer::yylex()
 // It is called by yylex but is not used as the mechanism to change file.
 // See <<EOF>>
 //! @cond dummy
-#if YY_FLEX_SUBMINOR_VERSION < 34
+#if YY_FLEX_MINOR_VERSION < 6 && YY_FLEX_SUBMINOR_VERSION < 34
 extern "C" int yywrap()
 #else
 int yyFlexLexer::yywrap()
diff --git a/src/triSurface/triSurface/interfaces/STL/readSTLASCII.L 
b/src/triSurface/triSurface/interfaces/STL/readSTLASCII.L
index bbc8bf2..f03e22e 100644
--- a/src/triSurface/triSurface/interfaces/STL/readSTLASCII.L
+++ b/src/triSurface/triSurface/interfaces/STL/readSTLASCII.L
@@ -53,7 +53,7 @@ int yyFlexLexer::yylex()
 // It is called by yylex but is not used as the mechanism to change file.
 // See <<EOF>>
 //! @cond dummy
-#if YY_FLEX_SUBMINOR_VERSION < 34
+#if YY_FLEX_MINOR_VERSION < 6 && YY_FLEX_SUBMINOR_VERSION < 34
 extern "C" int yywrap()
 #else
 int yyFlexLexer::yywrap()

Reply via email to