<?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>compile c++ code in uVision3?</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/38220/compile-c-code-in-uvision3</link><description> 
Hello all, 
I am trying to compile c++ code in Keil uVison3. Saving a file as
.cpp causes all color formatting to dissappear, and code will not
compile. There is no option to save as a cpp file either, i have to
do it manually. there is an option that</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: compile c++ code in uVision3?</title><link>https://community.arm.com/thread/101624?ContentTypeID=1</link><pubDate>Tue, 10 Feb 2009 09:39:30 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:5ed628fc-2a01-486d-a91e-989250c80c53</guid><dc:creator>Neil Kurzmam</dc:creator><description>&lt;p&gt;&lt;p&gt;
This cat comes pre-skinned.&lt;br /&gt;
There is an interrupt driven Serial Sample using ring buffers in the
sample folder of the compiler.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: compile c++ code in uVision3?</title><link>https://community.arm.com/thread/142219?ContentTypeID=1</link><pubDate>Tue, 10 Feb 2009 05:27:01 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:b34da422-d6bc-4f5c-929a-1ef8abd63b7e</guid><dc:creator>John Stevens</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;a href="http://www.keil.com/forum/docs/thread10074.asp"&gt;http://www.keil.com/forum/docs/thread10074.asp&lt;/a&gt;&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: compile c++ code in uVision3?</title><link>https://community.arm.com/thread/139042?ContentTypeID=1</link><pubDate>Tue, 10 Feb 2009 05:03:15 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:740b031f-96d6-4c06-94fc-cd42e73c7dcc</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
To some parts, you can make use of the improved namespace handling
of C++ even on a C51.&lt;/p&gt;

&lt;p&gt;
If you already have structs and write functions:&lt;/p&gt;

&lt;pre&gt;
struct a_struct {
    ...
};

void do_xx_on_a_struct(struct a_struct *my_struct);

struct a_struct my_struct;
do_xx_on_a_struct(&amp;amp;my_struct);
&lt;/pre&gt;

&lt;p&gt;
then you can change to:&lt;/p&gt;

&lt;pre&gt;
class a_class {
    public:
        ...
        void do_xx();
};
a_class my_object;
my_object.do_xx();
&lt;/pre&gt;

&lt;p&gt;
without extra cost. The problem comes when trying to use full
object orientation.&lt;/p&gt;

&lt;p&gt;
virtual methods isn&amp;#39;t so fun on a processor that requires call
tree analysis to globalize auto variables and parameters.&lt;/p&gt;

&lt;p&gt;
Dynamic object creations requires a heap, and a heap does not work
well unless the processor has a lot of RAM and preferably also a
virtual memory manager. It is evilishly hard to prove that the
application doesn&amp;#39;t fail from memory leaks or memory
fragmentation.&lt;/p&gt;

&lt;p&gt;
Templated code trades code size for reduced number of source lines
- but larger code size is normally also followed by a higher
production price when comparing within a processor family.&lt;/p&gt;

&lt;p&gt;
A very large part of the C++ runtime library isn&amp;#39;t applicable for
an embedded target since the hardware is missing or there are no
standardized ways to interface the C++ RTL methods with the existing
hardware.&lt;/p&gt;

&lt;p&gt;
C++ constructors/destructors are very powerful to take care of
leaks and avoid uninitialized struct members. But they represent
hidden code that may end up consuming a significant percentage of a
tiny processors available cycles.&lt;/p&gt;

&lt;p&gt;
Exceptions are &amp;quot;the way&amp;quot; to protect all resources and correctly
clean up after a failure. But if you don&amp;#39;t have a real stack, how can
you den unroll the stack?&lt;/p&gt;

&lt;p&gt;
operator overloading gives elegance, but in a way that hides the
computation cost. It is easy to get a very elegant program that does
not fulfill the real-time requirements. And a higher clock speed
affects the EMC tests and power consumption. And a faster chip may
affect the production cost.&lt;/p&gt;

&lt;p&gt;
In the end, C++ is a quite nice language. But for embedded targets
it is often better to write C:ish applications with limited
objectifications just for the namespaces and with limited use of
protected/private together with accessor methods.&lt;/p&gt;

&lt;p&gt;
The interesting thing is that C51 processors can be had with quite
huge flash sizes. But in my view, that flash should be used only for
quite small applications and with the extra space for storing const
data or (if IAP is supported) captured measures or similar. If the
code size starts to grow (making it more important to look at
namespaces and very clearly specified function and extensive data
structures) then I think it is better to switch to another processor
than to start looking for C++. After all, there isn&amp;#39;t a significant
price difference between 32-bit ARM chips or the C51 processors.&lt;/p&gt;

&lt;p&gt;
The important thing is that switching to a &amp;quot;traditional&amp;quot; 32-bit
processor do allow almost full use of the C++ extensions. Dynamic
memory allocations should preferably still be avoided (unless we are
talking about a processor with very much internal and/or external
RAM) except when the application can preallocate all data directly on
startup. The amount of non-deterministic behaviour should be
minimized as much as possible. The timing betweeen interrupts and
main loop or between tasks can&amp;#39;t be avoided but the only reason I can
see for intentionally adding non-determinism should be when
implementing a (pseudo) random number generator.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: compile c++ code in uVision3?</title><link>https://community.arm.com/thread/135667?ContentTypeID=1</link><pubDate>Tue, 10 Feb 2009 04:07:13 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:8d1c121c-621c-40cb-b031-0a4ee80d90de</guid><dc:creator>erik  malund</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;I believe that the Ceibo C++ compiler uses the same process. I
may be wrong there, though.&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
your belief is right, the Ceibo stuff generates Keil source.&lt;/p&gt;

&lt;p&gt;
My 10 cents worth on this: there seems to be more and more that do
not understand that, while a GHz PC can easily handle code that is
written for the programmers convenience, for a (relatively) slow 8
bitter you need to write for the processors convenience.&lt;/p&gt;

&lt;p&gt;
Erik&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: compile c++ code in uVision3?</title><link>https://community.arm.com/thread/135664?ContentTypeID=1</link><pubDate>Tue, 10 Feb 2009 00:33:50 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:79a25f1a-0a51-4e26-8b07-1f20d0c67a69</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
Never looked at Ceibo C++. Should have written Cfront however...
Not sure what Cfont is - Courier? ;)&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: compile c++ code in uVision3?</title><link>https://community.arm.com/thread/125227?ContentTypeID=1</link><pubDate>Tue, 10 Feb 2009 00:12:59 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:ff521588-39fb-47f8-9c79-6fdfd4db9051</guid><dc:creator>Christoph Franck</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;Now why did you have to wake memories of Cfont :)&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
I believe that the Ceibo C++ compiler uses the same process. I may
be wrong there, though.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: compile c++ code in uVision3?</title><link>https://community.arm.com/thread/114672?ContentTypeID=1</link><pubDate>Mon, 09 Feb 2009 14:26:38 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:083ee7be-247e-4e49-83d1-4f0e97493a24</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
&amp;quot;It can be done in C, it&amp;#39;s just not as pretty. In fact, the first
C++ compiler actually compiled C++ to C, and the output then had to
be compiled with a C compiler.&amp;quot;&lt;/p&gt;

&lt;p&gt;
Now why did you have to wake memories of Cfont :)&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: compile c++ code in uVision3?</title><link>https://community.arm.com/thread/102961?ContentTypeID=1</link><pubDate>Mon, 09 Feb 2009 12:54:01 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:6d8cf080-9aaa-4cb5-8793-9299176f6ee9</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;&amp;quot;Classes just would have been nice...&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
So, as Neil surmised, you didn&amp;#39;t really &lt;i&gt;&lt;b&gt;need&lt;/b&gt;&lt;/i&gt; classes
- you just thought they would be &amp;quot;nice&amp;quot;.&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;&amp;quot;...to impliment a few ring buffers&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
Yes, plenty of people have been happily using ring buffers in
plain ANSI &amp;#39;C&amp;#39; without needing (or even wanting) classes...&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: compile c++ code in uVision3?</title><link>https://community.arm.com/thread/77143?ContentTypeID=1</link><pubDate>Mon, 09 Feb 2009 12:29:05 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:d0e54256-aa75-4be4-8617-63144f9dcef1</guid><dc:creator>Thomas Stathes</dc:creator><description>&lt;p&gt;&lt;p&gt;
Classes just would have been nice to impliment a few ring buffers.
There is more than one way to skin a cat though, i will deal.&lt;br /&gt;
Thanks&lt;br /&gt;
Tom&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: compile c++ code in uVision3?</title><link>https://community.arm.com/thread/55376?ContentTypeID=1</link><pubDate>Mon, 09 Feb 2009 11:20:27 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:4a266890-c622-4f4a-93d2-513a007ee42b</guid><dc:creator>Christoph Franck</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;I need to be able to write classes, and this can not be done in
c.&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
It can be done in C, it&amp;#39;s just not as pretty. In fact, the first
C++ compiler actually compiled C++ to C, and the output then had to
be compiled with a C compiler.&lt;/p&gt;

&lt;p&gt;
There are C++ compilers for the 8051 out there, for example from
Ceibo, if you absolutely have to use classes, but the whole concept
is something the architecture of the &amp;#39;51 is not really suited for.
Also, the C++ compiler will actually do &amp;quot;Embedded C++&amp;quot;, which is a
limited subset of C++ that you may or may not be satisfied with.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: compile c++ code in uVision3?</title><link>https://community.arm.com/thread/89559?ContentTypeID=1</link><pubDate>Mon, 09 Feb 2009 11:06:06 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:3d54c3da-df29-4224-9129-f317b91ac3d9</guid><dc:creator>Neil Kurzmam</dc:creator><description>&lt;p&gt;&lt;p&gt;
I WANT to be able to write classes. Is most likely more
accurate.&lt;br /&gt;
If NEED is correct you will probably need a bigger CPU and a C++
Compiler to go with it.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: compile c++ code in uVision3?</title><link>https://community.arm.com/thread/89558?ContentTypeID=1</link><pubDate>Mon, 09 Feb 2009 10:16:32 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:0ae3b0ba-4851-4edc-8066-3ef4c4657903</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;a href="http://www.keil.com/product/isoansi.asp"&gt;http://www.keil.com/product/isoansi.asp&lt;/a&gt;&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: compile c++ code in uVision3?</title><link>https://community.arm.com/thread/55373?ContentTypeID=1</link><pubDate>Mon, 09 Feb 2009 08:53:46 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:42aa54d8-3479-4e08-9ebf-6547c62cf1d9</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
But was that post referring to C&lt;b&gt;51&lt;/b&gt; ?&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;&amp;quot;I need to be able to write classes, and this can not be done
in c.&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
Correct, it can&amp;#39;t; But C51 &lt;i&gt;&lt;b&gt;is&lt;/b&gt;&lt;/i&gt; a &amp;#39;C&amp;#39; compiler - not
C++&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: compile c++ code in uVision3?</title><link>https://community.arm.com/thread/55375?ContentTypeID=1</link><pubDate>Mon, 09 Feb 2009 08:49:33 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:8681f945-c79c-4a0d-a447-d8a13902db45</guid><dc:creator>Mike Kleshov</dc:creator><description>&lt;p&gt;&lt;p&gt;
Are you talking about C51? As far as I know, it does not support
C++. Besides, &amp;#39;C++ for 8051&amp;#39; doesn&amp;#39;t make much sense.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>