* [ECOS] eCos reference manual needs correction
@ 2008-04-30 11:32 Ilija Stanislevik
2008-04-30 12:16 ` Paul D. DeRocco
2008-04-30 12:17 ` Alex Schuilenburg
0 siblings, 2 replies; 3+ messages in thread
From: Ilija Stanislevik @ 2008-04-30 11:32 UTC (permalink / raw)
To: ecos-discuss
The eCos on-line reference manual
(http://ecos.sourceware.org/docs-2.0/ref/kernel-thread-create.html),
chapter Thread Entry Points and C++, gives an example which does not work.
The example states:
.
.
fred* object = static_cast<fred*>(objptr);
.
It is the static cast which makes compiler unhappy. The variable object is a pointer, while objptr is of type cyg_addrword_t, itself being an unsigned int. Knowing this, it is obvious why the compiler complains.
The issue was solved with the 'dangerous' reinterpret_cast instead of static _cast:
.
.
fred* object = reinterpret_cast<fred*>(objptr);
.
There is an other place within the example which needs the same intervention. Instead of
â¦
cyg_thread_create( â¦,
&fred::static_thread_aux,
static_cast<cyg_addrword_t>(&instance),
â¦);
â¦
I used
â¦
cyg_thread_create( â¦,
&fred::static_thread_aux,
reinterpret_cast<cyg_addrword_t>(&instance),
â¦);
â¦
Now I wonder if this is a general issue or it is limited to my Starter
Kit with AT91SAM926x for EB926x Evaluation Boards from Ronetix?
Is there a better, less 'dangerous' way to solve the issue?
Anyway, it seems that the manual needs to be corrected.
Thank you.
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [ECOS] eCos reference manual needs correction
2008-04-30 11:32 [ECOS] eCos reference manual needs correction Ilija Stanislevik
@ 2008-04-30 12:16 ` Paul D. DeRocco
2008-04-30 12:17 ` Alex Schuilenburg
1 sibling, 0 replies; 3+ messages in thread
From: Paul D. DeRocco @ 2008-04-30 12:16 UTC (permalink / raw)
To: ecos-discuss
> From: Ilija Stanislevik
>
> The eCos on-line reference manual
> (http://ecos.sourceware.org/docs-2.0/ref/kernel-thread-create.html),
> chapter Thread Entry Points and C++, gives an example which does not work.
> The example states:
> .
> .
>
> fred* object = static_cast<fred*>(objptr);
> .
>
> It is the static cast which makes compiler unhappy. The variable
> object is a pointer, while objptr is of type cyg_addrword_t,
> itself being an unsigned int. Knowing this, it is obvious why the
> compiler complains.
>
> The issue was solved with the 'dangerous' reinterpret_cast
> instead of static _cast:
> .
> .
> fred* object = reinterpret_cast<fred*>(objptr);
> .
>
> There is an other place within the example which needs the same
> intervention. Instead of
> …
> cyg_thread_create( …,
> &fred::static_thread_aux,
> static_cast<cyg_addrword_t>(&instance),
> …);
> …
> I used
> …
> cyg_thread_create( …,
> &fred::static_thread_aux,
> reinterpret_cast<cyg_addrword_t>(&instance),
> …);
> …
>
> Now I wonder if this is a general issue or it is limited to my Starter
> Kit with AT91SAM926x for EB926x Evaluation Boards from Ronetix?
>
> Is there a better, less 'dangerous' way to solve the issue?
>
> Anyway, it seems that the manual needs to be corrected.
It's possible that on some platforms, cyg_addrword_t is defined as void*, in which case static_cast would work. I suspect this was originally written with a C cast, and someone updated it to more "correct" C++ at some point.
But a reinterpret_cast is the correct thing to do. There's certainly no safer way to do it, since it really is about making the bits in a cyg_addrword_t into a pointer, to undo another complementary cast that occurred earlier.
--
Ciao, Paul D. DeRocco
Paul mailto:pderocco@ix.netcom.com
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [ECOS] eCos reference manual needs correction
2008-04-30 11:32 [ECOS] eCos reference manual needs correction Ilija Stanislevik
2008-04-30 12:16 ` Paul D. DeRocco
@ 2008-04-30 12:17 ` Alex Schuilenburg
1 sibling, 0 replies; 3+ messages in thread
From: Alex Schuilenburg @ 2008-04-30 12:17 UTC (permalink / raw)
To: Ilija Stanislevik; +Cc: ecos-discuss
Ilija Stanislevik wrote on 2008-04-30 10:03:
> The eCos on-line reference manual
> (http://ecos.sourceware.org/docs-2.0/ref/kernel-thread-create.html),
> chapter Thread Entry Points and C++, gives an example which does not work.
> The example states:
> .
> .
>
> fred* object = static_cast<fred*>(objptr);
> .
>
> It is the static cast which makes compiler unhappy. The variable object is a pointer, while objptr is of type cyg_addrword_t, itself being an unsigned int. Knowing this, it is obvious why the compiler complains.
>
> The issue was solved with the 'dangerous' reinterpret_cast instead of static _cast:
> .
> .
> fred* object = reinterpret_cast<fred*>(objptr);
> .
>
> There is an other place within the example which needs the same intervention. Instead of
> â¦
> cyg_thread_create( â¦,
> &fred::static_thread_aux,
> static_cast<cyg_addrword_t>(&instance),
> â¦);
> â¦
> I used
> â¦
> cyg_thread_create( â¦,
> &fred::static_thread_aux,
> reinterpret_cast<cyg_addrword_t>(&instance),
> â¦);
> â¦
>
> Now I wonder if this is a general issue or it is limited to my Starter
> Kit with AT91SAM926x for EB926x Evaluation Boards from Ronetix?
>
> Is there a better, less 'dangerous' way to solve the issue?
>
> Anyway, it seems that the manual needs to be corrected.
>
It looks like it is correct in the eCosPro docs:
http://www.ecoscentric.com/ecospro/doc.cgi/html/ref/kernel-thread-create.html
so the fix may be integrated in our next update.
-- Alex
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-04-30 11:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-30 11:32 [ECOS] eCos reference manual needs correction Ilija Stanislevik
2008-04-30 12:16 ` Paul D. DeRocco
2008-04-30 12:17 ` Alex Schuilenburg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).