Created attachment 472369 [details] Patch to quell the warning Description of problem: gcc 4.5 complains when compiling C++ code that include gdbm.h, in some situations. Did not get a response from gdbm's maintainers to the following patch. Version-Release number of selected component (if applicable): gdbm-1.8.3-6 How reproducible: Always Steps to Reproduce: $ cat foo.h #include <gdbm.h> class xx { public: GDBM_FILE dbf; }; [mrsam@octopus tmp]$ cat foo.c #include "foo.h" [mrsam@octopus tmp]$ g++ -c foo.c Actual results: In file included from foo.c:1:0: foo.h:3:10: warning: ‘xx’ has a field ‘xx::dbf’ whose type uses the anonymous namespace Expected results: Compilation without warnings Additional info:
Isn't that a bug in g++? The type doesn't use the anonymous namespace in the first place.
The typedef in question is a pointer to an anonymous struct. In C++, an anonymous struct/class is a class that's, essentially, in an anonymous namespace that is unique to each translation unit. In other words, each C++ module sees "GDBM_FILE" as a unique class. This example is just a warning. gcc will kick it up a notch, and will outright refuse to compile the following self-contained example: #include <gdbm.h> void bar(GDBM_FILE *p) { } $ g++ -c foo.c foo.c:3:22: error: non-local function ‘void bar(<anonymous struct>**)’ uses anonymous type Since each C++ module thinks GDBM_FILE is a unique class, it can't have external linkage.
The patch seems to solve the warning issue well.
gdbm-1.8.3-8.fc14 has been submitted as an update for Fedora 14. https://admin.fedoraproject.org/updates/gdbm-1.8.3-8.fc14
gdbm-1.8.3-8.fc14 has been pushed to the Fedora 14 stable repository. If problems still persist, please make note of it in this bug report.