Re: void* passed as funtion parameters?
"Robby" <Robby@discussions.microsoft.com> wrote in message
news:51F47836-9779-4A55-959B-2D442C986884@microsoft.com...
Hello Ben,
Maybe your C compiler vendor has fed you this line, but C++ support has
nothing to do with the capability of the target processor. It's purely a
compiler feature, both C and C++ compile to machine code just like
assembler
does, and if you don't use the expensive C++ features like exceptions, the
C++ code is often even smaller and more efficient than C.
Yes, your right, and its just that not all compiler manufacturers offer
C++
for MCUs either. 6 years ago when I was looking for C++ compilers for
MCUs,
there was not to many around but, yes they were existant. One of the good
ones I remember was Code warior but very expensive...
But, on another note Ben, why do some people put a cross on C++ when it
comes to microcontrollers. You can see here that C++ is really not that
welcome:
http://stackoverflow.com/questions/452139/writing-firmware-assembly-or-high-level
I'd guess it's because they've seen some really bloated C++ programs, they
think that all C++ programs have to be. It just isn't true. Well written
(i.e. respect typing, use prototypes, etc) C programs are also valid as C++.
And many C++-specific features have no extra cost at runtime (the compiler
has to work a little harder, or sometimes a lot harder in the case of
templates).
As you can see, the top rated answer in that thread is very pro-C++, for
many of the same reasons I am.
I don't know how old the article is, the posts only say the day/month.
There
seems to be the amount of months that the artical was posted from up on
the
top right of the page.
I am now searching for a new compiler that does both C/C++ for Microchip
Pics.
I am looking around but, this time I want to pick one that is solid with
minimal bugs. Any suggestions? My current compiler is horrible, and I
don't
want to make that mistake again.
There are a few different families of PIC, you have to specify which one.
It looks like IAR makes a compiler which will be quite good if their other
compilers are any indication. But there's no free "kickstart" edition.
There is a 30-day trial so you can see whether it's better behaved than the
one you've got.
You also might consider one of the other microcontroller families that are
about the same cost and feature set as PICs, with better compiler support.
For example, AVR and MSP430.
So, if the compiler can do C/C++, and one day I want to switch to C++, I
would be able to replace my structures to classes and also use all that
good
stuff that comes witn C++ such as templates and stl and so forth.
Yes, except that STL is pretty exception-heavy, so it isn't the best fit for
embedded code. But there are other libraries out there that would be fine.
In general the same methods that worked in C will work in C++, but you can
often get a lot better type-safety and program organization.
And don???t trust the alternative called "embedded C++". While a subset of
C++ that >excludes exceptions makes sense for microcontrollers, the folks
behind embedded >C++ didn't have a good understanding of runtime cost of
various features.
Okay!
Thanks for your feedback!
--
Best regards
Roberto
"Ben Voigt [C++ MVP]" wrote:
"Robby" <Robby@discussions.microsoft.com> wrote in message
news:2A2E2104-4D5B-43F9-A9E3-94EDCDEFDC0A@microsoft.com...
Hello Alex,
template<typename T>
void f1(T* p)
{
p->LK__F1 = 10;
}
wow! that's exactly what I need! But unfortunately PIC MCU'S don't
support
C++, they only support assembler or C. Some revolutionary MCU's such as
ARM
which are a little more powerfull are starting to accept C++. But not
PICs
... mayby someday they will.
Maybe your C compiler vendor has fed you this line, but C++ support has
nothing to do with the capability of the target processor. It's purely a
compiler feature, both C and C++ compile to machine code just like
assembler
does, and if you don't use the expensive C++ features like exceptions,
the
C++ code is often even smaller and more efficient than C. And don???t
trust
the alternative called "embedded C++". While a subset of C++ that
excludes
exceptions makes sense for microcontrollers, the folks behind embedded
C++
didn't have a good understanding of runtime cost of various features.
For example, AVR chips are just as simple as PICs but have g++ (a good
C++
compiler) capable of producing AVR code.
__________ Information from ESET NOD32 Antivirus, version of virus
signature database 4380 (20090829) __________
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com