[ https://issues.apache.org/jira/browse/MINIFI-286?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15994774#comment-15994774 ]
ASF GitHub Bot commented on MINIFI-286: --------------------------------------- Github user phrocker commented on the issue: https://github.com/apache/nifi-minifi-cpp/pull/88 @apiri The logic can be improved @jdye64 I'm in favor of removing the conditional expression entirely and using the c style for all versions since that will work. There's no point in using the C++ regex matching since it won't be available for all builds. If you really want to maintain it, you can do this: ``` diff --git a/libminifi/src/processors/GetFile.cpp b/libminifi/src/processors/GetFile.cpp index 2740793..9988029 100644 --- a/libminifi/src/processors/GetFile.cpp +++ b/libminifi/src/processors/GetFile.cpp @@ -24,8 +24,9 @@ #include <dirent.h> #include <limits.h> #include <unistd.h> -#if (__GNUC__ >= 4) -#if (__GNUC_MINOR__ < 9) +// if an older version of gcc that doesn't support <regex> +#ifdef __GNUC__ +#if (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 9)) #include <regex.h> #else #include <regex> @@ -268,8 +269,7 @@ bool GetFile::acceptFile(std::string fullName, std::string name, return false; #ifdef __GNUC__ -#if (__GNUC__ >= 4) -#if (__GNUC_MINOR__ < 9) +#if (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 9)) regex_t regex; int ret = regcomp(®ex, request.fileFilter.c_str(), 0); if (ret) @@ -280,7 +280,7 @@ bool GetFile::acceptFile(std::string fullName, std::string name, return false; #else try { - std::regex re(fileFilter); + std::regex re(request.fileFilter); if (!std::regex_match(name, re)) { return false; @@ -290,7 +290,6 @@ bool GetFile::acceptFile(std::string fullName, std::string name, return false; } #endif -#endif #else logger_->log_info("Cannot support regex filtering"); #endif ``` > GetFile filter fails to compile with GCC version greater than 4.9 > ----------------------------------------------------------------- > > Key: MINIFI-286 > URL: https://issues.apache.org/jira/browse/MINIFI-286 > Project: Apache NiFi MiNiFi > Issue Type: Bug > Components: C++ > Reporter: Jeremy Dyer > Assignee: Jeremy Dyer > Fix For: cpp-0.2.0 > > > GetFile.cpp has a macro which if the GCC version is greater than 4.9 a line > of code is introduced where "fileFilter" is used rather than > "request.fileFilter" which causes a compilation error. > GCC Version = 4.9.2 > /opt/nifi-minifi-cpp/libminifi/src/processors/GetFile.cpp: In member function > ‘bool org::apache::nifi::minifi::processors::GetFile::acceptFile(std::string, > std::string, const org::apache::nifi::minifi::processors::GetFileRequest&)’: > /opt/nifi-minifi-cpp/libminifi/src/processors/GetFile.cpp:283:21: error: > ‘fileFilter’ was not declared in this scope > std::regex re(fileFilter); -- This message was sent by Atlassian JIRA (v6.3.15#6346)