[En-Nut-Discussion] NutEventPostFromIrq and C++

Matthias Wilde ethernut at stockelache.de
Sun Jul 30 20:40:04 CEST 2006

Hi Harald,

to be honest, I saw the compiler errors and did not think in detail about
the problem.
Anyway I will try to explain what happened and my mistake:

Am 30.07.2006, 19:54 Uhr, schrieb Harald Kipp <harald.kipp at egnite.de>:

> Hi Matthias,
> I didn't check the final compiler result. For this specific case
> I'm quite sure that the macro version results in smallest and
> fastest code for C.

Your right, it might be faster with the inlined code, but at least we are
talking about one more call of a pointer address that should'nt be such a
problem also in the embedded world, but please forgive me when I am wrong,
I am x86 specialist, but I work hard to get also a expert on embedded ;-)

> I didn't think about any impact on C++. Actually I didn't understand
> your critics. If I'm not fully misunderstanding the procedure,
> the macro is handled by the preprocessor. Neither the C nor C++
> compiler will ever see any reference to NutEventPostFromIrq().

Sure, you can not think for every use case, and I do not expect that you
should even think in C++.
However, since I am still using C++, I am some how NutOS tester for
C++ usage. And if I see a problem, I just comment it to the admins.

> Further, the macro still uses a pointer reference to NUTTHREADINFO.
> I can't see, why a copy constructor would be required. The code
>          NUTTHREADINFO *tp = *qp;    \
>          tp->td_qpec++;              \

So what happend in my case was an error becouse of type mismatch, compiled
as C++ (in my sources) results in *tp = *qp. I get the following error

"invalid conversion from void* to NUTTHREADINFO*", and to fix this I did a
mistake and I got this copyconstuctor error. Sorry for confusion.

OK, now I just claim a missing cast:

           NUTTHREADINFO *tp = (NUTTHREADINFO *) *qp;    \

> could be interpreted as
>          (NUTTHREADINFO *(*qp))->td_qpec++; \
> Did I miss something?
No, sorry again.

This is fine! No copy contructor is needed!

Best regards


> Harald
> At 17:46 30.07.2006 +0200, you wrote:
>> Hello all,
>> I do not know exactly from which version you introduced the "new"   
>> NutEventPostFromIrq "function", might be 4.1.9rc4. However, I am not 
>>  really happy with this style. You replaced the function by a macro  
>> define which is not very helpfull using C++. So my code demands now  
>> copy constructors for NUTTHREADINFO....
>> However, I can not see any reason why you introduced a macro and do 
>> not  stick for the function, which would work fine for me. Just to 
>> make  clear, I do not claim the new modification / implementation of 
>> the  function itself. So, if there is not really a reason, please do 
>> not use  defines, which also recommends Scott Meyers  ;-)
> _______________________________________________
> En-Nut-Discussion mailing list
> En-Nut-Discussion at egnite.de
> http://www.egnite.de/mailman/listinfo.cgi/en-nut-discussion

Erstellt mit Operas revolutionärem E-Mail-Modul: http://www.opera.com/mail/

More information about the En-Nut-Discussion mailing list