Bug 64680 - pollution of global namespace with internal classes
Summary: pollution of global namespace with internal classes
Status: RESOLVED FIXED
Alias: None
Product: poppler
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: All All
: medium normal
Assignee: poppler-bugs
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-05-16 17:48 UTC by duelli
Modified: 2013-06-09 21:35 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
patch (wrapping classes in anonymous namespace) (884 bytes, patch)
2013-06-09 12:27 UTC, duelli
Details | Splinter Review

Description duelli 2013-05-16 17:48:17 UTC
In fofi/FoFiIdentifier.cc there are several internal classes MemReader, FileReader etc.
These are in the global namespace.

Incidentally, in our code there is a class FileReader, too.
It also has a constructor FileReaader(FILE*). Guess which code gets executed in FoFiIdentifier.cc ... the wrong one.
(Yes, FileReader is a rather dangerous name, and no, my FileReader is in the global namespace as well....)
This leads to a crash when opening a pdf containing fonts that need to be
looked up.

Trivial solution: wrap the internal classes with an anonymous namespace.
Or with namespace poppler. As the class is internal to this file, this won't cause problems.

Another good idea might be to introduce symbol (in)visiblity...

Best regards
and thank you for a really helpful library.
Comment 1 Albert Astals Cid 2013-06-01 16:48:27 UTC
Any chance you would send a patch?
Comment 2 duelli 2013-06-09 12:27:36 UTC
Created attachment 80563 [details] [review]
patch (wrapping classes in anonymous namespace)

just wraps the internal classes in namespace { ... }.
(Sorry for the delay, I was offline in holiday.)
Comment 3 Albert Astals Cid 2013-06-09 21:35:30 UTC
Will be in poppler 0.24.0


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.