[linux-audio-dev] [ot] [rant] gcc, you let me down one time too many
Clemens Ladisch
clemens at ladisch.de
Mon Jun 6 11:31:05 UTC 2005
Tim Goetze wrote:
> [Clemens Ladisch]
> > Tim Goetze wrote:
> >> Enter gcc version 3, which drops multi-line inline assembly support.
> >
> > The following compiles fine with gcc 3.3.3:
> >
> > __asm__ ("nop\n"
> > "nop\n");
>
> May compile fine, but like this a 100-line __asm__ goes well beyond my
> pain threshold when it comes to readability and maintainability.
You mean you want to omit \n and the quotes? That was always invalid
in both C and C++.
> > If your external functions use the correct type (i.e., a pointer to
> > the base type), the compiler will automatically cast class pointers in
> > the correct way. Otherwise, you have to cast to the base type
> > yourself whenever you 'export' a pointer.
>
> Believe me I have tried to come up with sensible solutions but there's
> quite a lot more to it than just fixing a few thousand pointer casts.
>
> Basically, you can't rectify the problem because the basic Python
> Object type (from which my types are derived) is actually at a fixed
> offset into a Python garbage-collected structure.
I assumed your objects should just be accessed from Python, but it's
of course different if they are to be managed by Python.
You could introduce an additional layer of indirection: hold a
separate C++ object with a pointer from the Python-managed object.
> The following is OK for an older g++:
>
> void
> Descriptor<AmpIV>::setup()
> {
> UniqueID = 1794;
> ...
> }
>
> but g++ since 4.0 wants this instead:
>
> template <> void
> Descriptor<AmpIV>::setup()
> {
> ...
> }
>
> I cannot for the life of me imagine a good reason why "template <>"
> should be necessary.
It's needed because
A) the standard says so;
B) Descriptor is still a template, even if all template parameters
happen to be specialized.
> "setup()" was never declared as a template, let alone one with an
> empty template parameter.
I guess you don't want to hear it, but if setup() was declared as a
template, you would have to write something like this:
template <> template <class T> void
Descriptor<AmpIV>::setup<T>()
{ ... }
> If this is indeed prescribed by the language standard, I'll have a
> very, very hard time getting over it.
For completely specialized templates, you can avoid the "template<>"
stuff like this:
typedef Descriptor<AmpIV> Amp4Descriptor; // no "template" needed here
void Amp4Descriptor::setup() {...}
> It may not look like much but you have to understand that to me
> coding is also an exercise in aesthetics.
"aesthetics" is not a keyword in C++. ;-)
Regards,
Clemens
More information about the Linux-audio-dev
mailing list