[Speex-dev] Strange style of includes
pavel at summit-tech.ca
Mon Jun 21 16:24:49 PDT 2010
I'm just curious, who and why came up with that strange way to write includes:
# include "speex_types.h"
# include <speex/speex_types.h>
I personally consider it a bug. If I use speex then obviously I should not have _BUILD_SPEEX defined. The broken behavior happens in this simple scenario:
1) I check out latest git version to ./src/speex
2) My system has an older "release" version installed to regular install location.
3) I want to use the version I just checked out, I include filed this way: "...whatever/src/speex/speex_bits.h"
Broken behavior: instead of using files from check out version, speex includes will include system installed versions of old speex! That's just bad, I've never seen anything like that
I'll attempt to answer the "why" question... speex also has Symbian port, and just like everything is ugly crap in Symbian world, their version of gcc is also broken and you can't include headers relative to the directory of current file and that approach with <path/to/file.h> would probably fix that problem in Symbian. I think _build_speex thing should be removed, plus have_config_h usually has the same meaning: to indicate that the library is being build and not used.
Speex code uses EXPORT to mark public api functions. If default visibility is hidden then it's all ok, but I'd personally use static for private functions if they aren't referenced across different files. Also, there is a portable way to support visibility modifiers: http://gcc.gnu.org/wiki/Visibility, but for windows SPEEX_API (or EXPORT) would need to be added to .h and .c files.
I also use one file compilation: libspeex.c that includes all of speex so that speex can be used in any library by simply adding reference to that .c file to a makefile (just like pthreads does). The is a minor problem though: nb_celp.c and sb_celp.c redefine the same macro with different values: LSP_MARGIN, LSP_DELTA1, LSP_DELTA2 (which result in a warning) and _kiss_fft_guts.h doesn't have header guards (results in errors).
I really like speex, clean code and easy to read, so I just wanted to somehow ask for a little improvement if that's possible :)
More information about the Speex-dev