<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>convert unsigned int to class pointer</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/30429/convert-unsigned-int-to-class-pointer</link><description> 
Hello together, 

 
i was trying to find out, how to cast an unsigned int to a class
pointer. 
I&amp;#180;m using a stm32 under &amp;#181;Vision4. 
I read something about reinterpret casts, and that they&amp;#180;re not
that runtime efficient. 
And i don&amp;#180;t see (know) the reason</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: convert unsigned int to class pointer</title><link>https://community.arm.com/thread/140584?ContentTypeID=1</link><pubDate>Sun, 12 May 2013 11:55:04 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:b9190b9c-8c9b-40d9-bd99-72dfc077702f</guid><dc:creator>Hagfried Justafoosche</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;That makes no sense.&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
You may or may not agree with it, but linguistically it does make
perfect sense.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: convert unsigned int to class pointer</title><link>https://community.arm.com/thread/137015?ContentTypeID=1</link><pubDate>Sun, 12 May 2013 11:14:26 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:d31bf087-7281-465d-b330-e510ec25c436</guid><dc:creator>HansBernhard Broeker</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;And on the other hand, when my knowledge isn&amp;acute;t enough to
estimate if a c++ feature is suitable for a &amp;micro;Controler/embedded
system, then i rather reinvent the wheel instead of using something
where i don&amp;acute;t know what system requirements are needed.&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
That makes no sense. If you not just lack basic knowledge to make
an informed decision, but &lt;b&gt;know&lt;/b&gt; you lack it, then it&amp;#39;s
&lt;b&gt;never&lt;/b&gt; the right conclusion to just make the decision anyway.
You should improve your knowledge instead.&lt;/p&gt;

&lt;p&gt;
Like I said: re-inventing the wheel is embarrassing enough on its
own, even if you&amp;#39;re lucky enough that yours don&amp;#39;t come out square.
But it&amp;#39;s truly ridiculous when you do that while already sitting in a
wheeled vehicle, so all you would have had to do to spare you the
effort is take a look down out the window.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: convert unsigned int to class pointer</title><link>https://community.arm.com/thread/137013?ContentTypeID=1</link><pubDate>Sun, 12 May 2013 08:12:15 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:fa317460-97a2-48c0-bb52-984814065cb7</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
So either program in C.&lt;/p&gt;

&lt;p&gt;
Or spend some hours looking at an entry-level C++ textbook. That
C++ book will quite quickly cover these issues.&lt;/p&gt;

&lt;p&gt;
But as Hans-Bernhard Broeker said, the base form of the word
&amp;quot;ignorant&amp;quot; means:&lt;br /&gt;
- Lacking knowledge or awareness in general; uneducated or
unsophisticated.&lt;br /&gt;
- Lacking knowledge, information, or awareness about something in
particular: &amp;quot;ignorant of astronomy&amp;quot;.&lt;/p&gt;

&lt;p&gt;
In this case, you are lacking knowledge of C++. So you try to bend
it to write C programs when C++ has specifically added functionality
for object-oriented programs.&lt;/p&gt;

&lt;p&gt;
C++ was designed to allow C code to be compiled with a minimum of
adjustments, to allow incremental move from strict C to full C++. But
that doesn&amp;#39;t mean you should write object-oriented code (which is in
the C++ domain) by using C constructs like typecasting of untyped
pointers etc.&lt;/p&gt;

&lt;p&gt;
It doesn&amp;#39;t take many hours to pick up what the important C++
additions are - but you should preferably settle for using a single
base class and ignore that C++ also supports multiple inheritance.
Having multiple base classes means people can&amp;#39;t read the source code
and actually understand the actual implications of call order for
constructors, destructors etc.&lt;/p&gt;

&lt;p&gt;
If you are good with C++, then there are even special books that
concentrates on just describing the differences from C to C++.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: convert unsigned int to class pointer</title><link>https://community.arm.com/thread/137011?ContentTypeID=1</link><pubDate>Sun, 12 May 2013 06:02:45 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:ad849a34-fff1-475e-a769-57a7cfec2a49</guid><dc:creator>HansBernhard Broeker</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;how can i ignore someting i don&amp;acute;t know about?&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
Easily --- because the original, literal meaning of &amp;quot;to ignore&amp;quot;
&lt;b&gt;is&lt;/b&gt; &amp;quot;to know nothing about&amp;quot;. Only later did it gain the
additional meaning of &amp;quot;to not make use of something you have&amp;quot;&lt;/p&gt;

&lt;p&gt;
But really, you must be kidding. There&amp;#39;s just no way you believe
you&amp;#39;re programming C++ and not know about inheritance.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: convert unsigned int to class pointer</title><link>https://community.arm.com/thread/128182?ContentTypeID=1</link><pubDate>Sun, 12 May 2013 06:02:00 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:897a5563-c05f-457f-ad55-9328975ebedb</guid><dc:creator>PinkyAndBrain JFK</dc:creator><description>&lt;p&gt;&lt;p&gt;
Don&amp;acute;t u think, that my questions mostly refer to a suffer of
knowledge rather than doing &amp;quot;wrong&amp;quot; things with awareness?&lt;br /&gt;
And on the other hand, when my knowledge isn&amp;acute;t enough to
estimate if a c++ feature is suitable for a &amp;micro;Controler/embedded
system, then i rather reinvent the wheel instead of using something
where i don&amp;acute;t know what system requirements are needed.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: convert unsigned int to class pointer</title><link>https://community.arm.com/thread/120054?ContentTypeID=1</link><pubDate>Sun, 12 May 2013 05:53:52 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:249bad48-e5bf-4f29-b50b-8a3843dcca9b</guid><dc:creator>HansBernhard Broeker</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;But what is the reason not to do so?&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
The reason is that currently you&amp;#39;re fighting your tools instead of
using them properly. The reason is that you&amp;#39;re reinventing the wheel
while riding a train.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: convert unsigned int to class pointer</title><link>https://community.arm.com/thread/128183?ContentTypeID=1</link><pubDate>Sun, 12 May 2013 05:53:49 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:c696b039-455f-4aeb-b5c7-b2ea51419115</guid><dc:creator>PinkyAndBrain JFK</dc:creator><description>&lt;p&gt;&lt;p&gt;
how can i ignore someting i don&amp;acute;t know about?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: convert unsigned int to class pointer</title><link>https://community.arm.com/thread/120052?ContentTypeID=1</link><pubDate>Sun, 12 May 2013 05:18:07 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:90fb0cc7-eead-4d4e-820e-7a3d16494952</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
&amp;quot;But what is the reason not to do so?&lt;/p&gt;

&lt;p&gt;
The main reason? That you are programming in C with the C++
language.&lt;/p&gt;

&lt;p&gt;
That you are ignoring that C++ was designed for objects, and so
added specific language extensions for inheritance from base classes.
That C++ added support for virtual methods, constructors,
destructors, ...&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: convert unsigned int to class pointer</title><link>https://community.arm.com/thread/107112?ContentTypeID=1</link><pubDate>Sun, 12 May 2013 04:48:06 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:2f3ee558-e4f6-430b-8f3c-5bb0af3291f1</guid><dc:creator>PinkyAndBrain JFK</dc:creator><description>&lt;p&gt;&lt;p&gt;
Ah, &amp;quot;inheritance&amp;quot; was the word i needed by writing &amp;quot;descent&amp;quot;.&lt;br /&gt;
But afaik, templates also critical in embedded systems.&lt;br /&gt;
At the moment i&amp;acute;m doing it by casteing the usigned int back to
a class pointer and it works.&lt;br /&gt;
But what is the reason not to do so?&lt;br /&gt;
An unsigned int has the width of the asdresses wich exists in a 32bit
Controller.&lt;br /&gt;
Or is it just the danger to cast it into an type wich it
doesen&amp;acute;t really point to?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: convert unsigned int to class pointer</title><link>https://community.arm.com/thread/81227?ContentTypeID=1</link><pubDate>Sat, 11 May 2013 10:07:40 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:67a3074d-6037-4150-8065-799bc2d30008</guid><dc:creator>PinkyAndBrain JFK</dc:creator><description>&lt;p&gt;&lt;p&gt;
thanks for keywords! I&amp;acute;ll check for them.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: convert unsigned int to class pointer</title><link>https://community.arm.com/thread/61920?ContentTypeID=1</link><pubDate>Sat, 11 May 2013 06:47:38 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:3f31f30f-ca7a-420f-87d5-88e562936855</guid><dc:creator>HansBernhard Broeker</dc:creator><description>&lt;p&gt;&lt;p&gt;
That looks like you&amp;#39;re going about this whole thing bass-ackwards.
C++ has way better methods for doing that, involving either templates
(see STL&amp;#39;s &amp;lt;dequeue&amp;gt; et al.) or inheritance of members and
methods from shared base classes.&lt;/p&gt;

&lt;p&gt;
Even in C, pointers aren&amp;#39;t really all that compatible with
integers. You shouldn&amp;#39;t even think about it for C++ object
pointers.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>