[antlr-interest] 2.7.2 C++ library problems

Dan Muller dmuller at creativesolutions.com
Fri Jan 31 04:25:11 PST 2003


I just downloaded antlr 2.7.2, the zip file version. I'm trying to build it
with VC7, which by itself is not too difficult, starting from the existing
VC6 .dsp file. I've run into a few minor annoyances that were easily fixed.
Once I've gotten further along and verified the changes, I'd be happy to
send a diff if someone will tell me where to send it and how to generate it.
(I have the cygwin tools handy, I'm just not conversant with generate patch
diffs.)

Problems fixed so far:

1. The DSP file was apparently badly out of date. It referenced .cpp files
that no longer existed (the classes were all inline) and was missing one
.cpp file. (Might be missing more, I'll find out soon.)

2. The ANTLR_API macro is used on classes to provide VC++'s
_declspec(import/export) modifier. This causes various warnings when such
classes participate in inheritance trees with non-exported classes, or if
the exported classes contain data members of non-exported classes. After
years of dealing with VC++ DLL construction, I've determined that the best
way to do deal with this is to never use these modifiers on classes.
Instead, I apply them to all public non-inline member functions, and to
protected member functions if it's expected that code outside of the DLL
will inherit from a class. This allows the exported classes to be used much
more flexibly without warnings, and probably also reduces export library
sizes. (The latter's not a big issue for this small library.)

3. The non-standard "extern template instantiation" construct causes
warnings. In one case it wasn't necessary, because the class template in
question is entirely inline. (Note that member functions defined in a class
body are alway inline; at least one of the library authors seemed unsure
about this.)  In the other two cases, I think these were needed due to do
problems with the VC6 std lib, so I augmented the #ifdefs to exclude these
constructs for VC7.

I've gotten the library to compile and link cleanly. Remains to be seen if
it works; I have to come back up to speed on ANTLR, since I haven't used it
in a couple of years.

- Dan Muller


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list