From 47575aabf272df2ac4ec9cc0bcf9fd89b1c1512a Mon Sep 17 00:00:00 2001 From: Vaggelis Papoutsis Date: Thu, 13 Mar 2025 18:30:40 +0200 Subject: [PATCH] COMP: compilation with clang (c++17) and older flex files (fixes #3337) - The register keyword has been removed from c++17 but old flex versions (version < 2.6.0) produce code including it, leading to compilation errors when using clang (despite disabling the diagnostic). gcc compiles but issues warnings. - use '#define register' as empty as a workaround --- .../utilities/mesh/conversion/ansysToFoam/ansysToFoam.L | 3 +++ .../mesh/conversion/fluent3DMeshToFoam/fluent3DMeshToFoam.L | 3 +++ .../mesh/conversion/fluentMeshToFoam/fluentMeshToFoam.L | 3 +++ .../utilities/mesh/conversion/gambitToFoam/gambitToFoam.L | 3 +++ src/fileFormats/stl/STLAsciiParseFlex.L | 3 +++ .../chemistryReaders/chemkinReader/chemkinLexer.L | 3 +++ 6 files changed, 18 insertions(+) diff --git a/applications/utilities/mesh/conversion/ansysToFoam/ansysToFoam.L b/applications/utilities/mesh/conversion/ansysToFoam/ansysToFoam.L index 5838ed309f..782349b50d 100644 --- a/applications/utilities/mesh/conversion/ansysToFoam/ansysToFoam.L +++ b/applications/utilities/mesh/conversion/ansysToFoam/ansysToFoam.L @@ -62,6 +62,9 @@ Description // Flex may use register, which is deprecated and incompatible with C++17 #pragma clang diagnostic ignored "-Wdeprecated-register" +// A 'nothing' define to effectively remove from code as well (issue #3337) +#undef register +#define register using namespace Foam; diff --git a/applications/utilities/mesh/conversion/fluent3DMeshToFoam/fluent3DMeshToFoam.L b/applications/utilities/mesh/conversion/fluent3DMeshToFoam/fluent3DMeshToFoam.L index 7e0686d064..10738061c2 100644 --- a/applications/utilities/mesh/conversion/fluent3DMeshToFoam/fluent3DMeshToFoam.L +++ b/applications/utilities/mesh/conversion/fluent3DMeshToFoam/fluent3DMeshToFoam.L @@ -56,6 +56,9 @@ Description // Flex may use register, which is deprecated and incompatible with C++17 #pragma clang diagnostic ignored "-Wdeprecated-register" +// A 'nothing' define to effectively remove from code as well (issue #3337) +#undef register +#define register // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/applications/utilities/mesh/conversion/fluentMeshToFoam/fluentMeshToFoam.L b/applications/utilities/mesh/conversion/fluentMeshToFoam/fluentMeshToFoam.L index d74f4ab01c..1f79995445 100644 --- a/applications/utilities/mesh/conversion/fluentMeshToFoam/fluentMeshToFoam.L +++ b/applications/utilities/mesh/conversion/fluentMeshToFoam/fluentMeshToFoam.L @@ -63,6 +63,9 @@ Description // Flex may use register, which is deprecated and incompatible with C++17 #pragma clang diagnostic ignored "-Wdeprecated-register" +// A 'nothing' define to effectively remove from code as well (issue #3337) +#undef register +#define register // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/applications/utilities/mesh/conversion/gambitToFoam/gambitToFoam.L b/applications/utilities/mesh/conversion/gambitToFoam/gambitToFoam.L index c29bff53e5..0dbb0d5278 100644 --- a/applications/utilities/mesh/conversion/gambitToFoam/gambitToFoam.L +++ b/applications/utilities/mesh/conversion/gambitToFoam/gambitToFoam.L @@ -51,6 +51,9 @@ Description // Flex may use register, which is deprecated and incompatible with C++17 #pragma clang diagnostic ignored "-Wdeprecated-register" +// A 'nothing' define to effectively remove from code as well (issue #3337) +#undef register +#define register using namespace Foam; diff --git a/src/fileFormats/stl/STLAsciiParseFlex.L b/src/fileFormats/stl/STLAsciiParseFlex.L index 0f66ea3eeb..2c93fdb7e9 100644 --- a/src/fileFormats/stl/STLAsciiParseFlex.L +++ b/src/fileFormats/stl/STLAsciiParseFlex.L @@ -44,6 +44,9 @@ Description // Flex may use register, which is deprecated and incompatible with C++17 #pragma clang diagnostic ignored "-Wdeprecated-register" +// A 'nothing' define to effectively remove from code as well (issue #3337) +#undef register +#define register using namespace Foam; diff --git a/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinLexer.L b/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinLexer.L index 4c01e3ea67..a77953325d 100644 --- a/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinLexer.L +++ b/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinLexer.L @@ -39,6 +39,9 @@ License // Flex may use register, which is deprecated and incompatible with C++17 #pragma clang diagnostic ignored "-Wdeprecated-register" +// A 'nothing' define to effectively remove from code as well (issue #3337) +#undef register +#define register // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //