[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] More on C macros vs. C++ templates

From: Dave Hylands
Subject: Re: [avr-gcc-list] More on C macros vs. C++ templates
Date: Fri, 28 Apr 2006 10:26:46 -0700

Hi Ned,

> The C++ version is also missing a bit of functionality but it would be
> easy to add. I think at the time I didn't fully appreciate what was
> affecting the size and could probably get the C++ one to be as small
> as the C one now that I understand whats going on.

OK, here's a modified version of yours that generates the same size
object file using GCC 4.1.0 (actually, the C++ version is 2 bytes
larger because of a bad register allocation choice, but who's

Thanks for the improvements - I'll incorporate them back into my version.

I also made the C interface parameterizable for IndexType and
EntryType, added the missing functions to the C++ version (though I'm
not sure that they should be public at all), and added some comments.

I added CBUF_GetPopEntryPtr and CBUF_AdvancePopIdx for cases where
you're using a circular buffer of structures and don't want to make a
copy outside of the circular buffer.

CBUF_GetPopEntryPtr allows you to snag a pointer to the structure
inside the circular buffer, and once you've finished with it, you can
call CBUF_AdvancePopIdx to "consume" the item.

So, for the intended purposes, the GetEntryPtr and Advance functions
should be public.

Dave Hylands
Vancouver, BC, Canada

reply via email to

[Prev in Thread] Current Thread [Next in Thread]