Switch to custom deleter type for unique_ptr 49/308749/1
authorSlava Barinov <v.barinov@samsung.com>
Fri, 29 Mar 2024 12:13:32 +0000 (15:13 +0300)
committerSlava Barinov <v.barinov@samsung.com>
Fri, 29 Mar 2024 12:13:32 +0000 (15:13 +0300)
This prevents the error:

 src/parser/exec-checker/src/exec_checker.cc:202:42: error: ignoring attributes on template argument 'int (*)(FILE*)' [-Werror=ignored-attributes]
 202 |   std::unique_ptr<FILE, decltype(fclose)*> fp_auto(fp, fclose);
     |                                          ^

When building with new toolchain

Change-Id: I3b0b71ddb2c887d349e783e5ad3a6d1b1bbb561e

src/parser/exec-checker/src/exec_checker.cc

index 40f7caf..655995c 100644 (file)
@@ -199,7 +199,13 @@ bool ExecChecker::CheckMainSymbol() {
     return false;
   }
 
-  std::unique_ptr<FILE, decltype(fclose)*> fp_auto(fp, fclose);
+  struct file_closer {
+    void operator() (FILE* f) const {
+      fclose(f);
+    }
+  };
+
+  std::unique_ptr<FILE, file_closer> fp_auto(fp);
   header h;
   size_t nbytes = fread(h.c, 1, sizeof(h), fp);
   if (nbytes < 2) {