[vorbis-dev] Building vorbis - please help
David A. Gatwood
dgatwood at gatwood.net
Mon Jan 29 22:04:44 PST 2001
On Tue, 30 Jan 2001, Michael Smith wrote:
> Most of the rest (the actual errors) are because you're compiling C
> with a C++ compiler. C is NOT a subset of C++, unlike what some people
> seem to think. Don't expect that to work, and don't expect us to work
> around it. Set your compiler to compile as C (if it can't, then your
> compiler is for a language other than what vorbis is written in - we're
> not going to change it to that, just like we wouldn't make changes for
> someone who wanted to compile vorbis with visual basic).
That argument is a rather weak one. C is very, very close to a proper
subset of C++. In early incarnations, it was a proper subset. C++ was
originally a series of C macros. While C++ is no longer expressible in
that way, it is still roughly a superset of C. Thus, well-written C code
should compile with a C++ compiler, with a handful of minor caveats.
First, C++ is particularly picky about casts. An anal-retentive C
compiler could also be that picky if it wanted to be, in most cases.
There's nothing wrong with adding the casts -- no C compiler is going to
complain -- so it seems reasonable to add them.
Those implicit cast warnings are the only problems I had with building ao
and ogg using g++. Vorbis, however, is another story, as it just happens
to hit one of the very tiny places where C isn't a perfect subset,
specifically the C++ notion of "this".
The files lib/codebook.c, lib/sharedbook.c, and about ten files in vq use
a variable called "this". Since that variable has a special meaning in
C++, you have a slight problem. There are two workarounds. The hack is
to add -fthis-is-variable to the command line when compiling these files.
This option exists because "this" has not always been a special variable.
The correct solution, though, is to use a more reasonable variable name.
Since the changes required to make ogg/vorbis build using C++ are so
minor, it seems like a good idea to make them. The "this" fixes are
pretty small, but important. The remaining casts are trivial, but
If I can make it build with g++ in half of Roswell, it shouldn't take
someone more than a couple of hours to make all the changes to make it
compile cleanly in C++ as well as C.
Check out my weekly web comic:
--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'vorbis-dev-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the Vorbis-dev