sunqi800 / gperftools

Automatically exported from code.google.com/p/gperftools
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

heap-checker friend declaration of main might not be necessary and can cause a conflict #613

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
heap-checker.h contains the following friend declaration of main:
friend int main(int, char**).
C99 allows another declaration of main, i.e. int main(int, char**, char**), and 
if code uses it and includes the heap-checker header, this might result in a 
conflict, e.g.

error: declaration of C function 'int main(int, char**, char**)' conflicts with
 int main(int argc, char* argv[], char** envp)

Actually the comment above the friend declaration of main() mentions that this 
is required to get the unittest working and for other internal usage, but I'm 
not completely sure if this is true as long as I'm able to build and run the 
unittest removing the declaration.

diff --git a/src/gperftools/heap-checker.h b/src/gperftools/heap-checker.h
index 6c1187f..5a87d8d 100644
--- a/src/gperftools/heap-checker.h
+++ b/src/gperftools/heap-checker.h
@@ -240,9 +240,6 @@ class PERFTOOLS_DLL_DECL HeapLeakChecker {
   friend void NamedTwoDisabledLeaks();
   friend void* RunNamedDisabledLeaks(void*);
   friend void TestHeapLeakCheckerNamedDisabling();
-  // TODO(csilvers): remove this one, at least
-  friend int main(int, char**);
-

   // Actually implements IgnoreObject().
   static void DoIgnoreObject(const void* ptr);

What version of the product are you using? On what operating system?
gperftools version:
gperftools-2.1

OS:
$ uname -a
Linux localhost.localdomain 3.12.10-300.fc20.x86_64 #1 SMP Thu Feb 6 22:11:48 
UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

Original issue reported on code.google.com by davide.i...@10gen.com on 27 Mar 2014 at 8:52

GoogleCodeExporter commented 9 years ago
Thanks for raising it.

Original comment by alkondratenko on 27 Mar 2014 at 8:54

GoogleCodeExporter commented 9 years ago
Thanks again. Applied.

Original comment by alkondratenko on 29 Mar 2014 at 8:33