EmbeddedRelated.com
Forums

Open Source EC++ Implementation?

Started by Himanshu Chauhan July 28, 2007
ammonton@cc.full.stop.helsinki.fi wrote:
> Himanshu Chauhan <hs.chauhan@gmail.com> wrote: > >> How does the Mac OS X use EC++ for their driver model. I know they use GCC. > > AFAIK they don't use EC++, but I/O Kit drivers are prohibited from using > exceptions or RTTI. See > <http://developer.apple.com/documentation/devicedrivers/Conceptual/IOKitFu........./doc/uid/TP0000013-TPXREF104> > and the rest of the I/O Kit documentation. > > -a
They use EC++. Please check this: http://www.kernelthread.com/mac/osx/arch_xnu.html <excerpt> I/O Kit, the object-oriented device driver framework of the XNU kernel is radically different from that on traditional systems. I/O Kit uses a restricted subset of C++ (based on Embedded C++) as its programming language. This system is implemented by the libkern library. Features of C++ that are not allowed in this subset include: * exceptions * multiple inheritance * templates * RTTI (run-time type information), although I/O Kit has its own run-time typing system </excerpt> How they do it with GCC, I don't know! --Himanshu
Himanshu Chauhan <hs.chauhan@gmail.com> wrote:

> They use EC++. Please check this: > http://www.kernelthread.com/mac/osx/arch_xnu.html
I've never seen it named in the documentation, though. -a
Chris Hills wrote:
> C++ isn't modular but C is.
I hope you'll forgive me, but will you please elaborate on this claim? -- Michael N. Moran (h) 770 516 7918 5009 Old Field Ct. (c) 678 521 5460 Kennesaw, GA, USA 30144 http://mnmoran.org "So often times it happens, that we live our lives in chains and we never even know we have the key." "Already Gone" by Jack Tempchin (recorded by The Eagles) The Beatles were wrong: 1 & 1 & 1 is 1
Himanshu Chauhan wrote:
> They use EC++. Please check this: > > http://www.kernelthread.com/mac/osx/arch_xnu.html > > <excerpt> > I/O Kit, the object-oriented device driver framework of the XNU kernel > is radically different from that on traditional systems. > > I/O Kit uses a restricted subset of C++ (based on Embedded C++) as its > programming language. This system is implemented by the libkern library. > Features of C++ that are not allowed in this subset include: > > * exceptions > * multiple inheritance > * templates > * RTTI (run-time type information), although I/O Kit has its own > run-time typing system > </excerpt> > > How they do it with GCC, I don't know!
I suspect that it is done by a combination of convention and using some flags to the compiler: -fno-exceptions -fno-rtti This is what I do with my embedded C++ code, though I allow templates and MI at the interface level. OTOH, I don't use STL and delete/free. -- Michael N. Moran (h) 770 516 7918 5009 Old Field Ct. (c) 678 521 5460 Kennesaw, GA, USA 30144 http://mnmoran.org "So often times it happens, that we live our lives in chains and we never even know we have the key." "Already Gone" by Jack Tempchin (recorded by The Eagles) The Beatles were wrong: 1 & 1 & 1 is 1
Michael N. Moran wrote:
> Himanshu Chauhan wrote: >> They use EC++. Please check this: >> >> http://www.kernelthread.com/mac/osx/arch_xnu.html >> >> <excerpt> >> I/O Kit, the object-oriented device driver framework of the XNU kernel >> is radically different from that on traditional systems. >> >> I/O Kit uses a restricted subset of C++ (based on Embedded C++) as its >> programming language. This system is implemented by the libkern library. >> Features of C++ that are not allowed in this subset include: >> >> * exceptions >> * multiple inheritance >> * templates >> * RTTI (run-time type information), although I/O Kit has its own >> run-time typing system >> </excerpt> >> >> How they do it with GCC, I don't know! > > I suspect that it is done by a combination > of convention and using some flags to the > compiler: > > -fno-exceptions > -fno-rtti > > This is what I do with my embedded C++ code, > though I allow templates and MI at the interface > level. OTOH, I don't use STL and delete/free. > >
You use EC++ in your embedded code? Which processors? At least vote count reached to one. :) I have still not decided which way to go. Whats you opinion on EC++? Could you please elaborate on the usage of GCC on the EC++ respect? I don't expect code to be optimized but should be at least equivalent to plain C. I want to use power of C and modular, not structural, pattern of C++. --Himanshu
ammonton@cc.full.stop.helsinki.fi wrote:
> Himanshu Chauhan <hs.chauhan@gmail.com> wrote: > >> They use EC++. Please check this: >> http://www.kernelthread.com/mac/osx/arch_xnu.html > > I've never seen it named in the documentation, though. > > -a
I have also read in some documentation but I don't know which one, so I can't quote. It was 2 years back when I was learning about I/O kit drivers. --Himanshu
In article <GGmri.10446$ae7.3602@bignews7.bellsouth.net>, Michael N. 
Moran <mnmoran@bellsouth.net> writes
>Chris Hills wrote: >> C++ isn't modular but C is. > >I hope you'll forgive me, but will you >please elaborate on this claim?
A little facetious but C is modular and C++ OO :-) You can do quite good OO programming in C too though both quite the same as there is no inheritance. It seemed the OP had the answer before asking the question. He had chosen C++ regardless of how appropriate it was and would damned well make it fit. -- \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ \/\/\/\/\ Chris Hills Staffs England /\/\/\/\/ /\/\/ chris@phaedsys.org www.phaedsys.org \/\/\ \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
Himanshu Chauhan wrote:
> Michael N. Moran wrote: >> Himanshu Chauhan wrote: >>> How they do it with GCC, I don't know! >> I suspect that it is done by a combination of >> convention and using some flags to the compiler: >> >> -fno-exceptions -fno-rtti >> >> This is what I do with my embedded C++ code, though I >> allow templates and MI at the interface level. OTOH, I >> don't use STL and delete/free. >> >> > > You use EC++ in your embedded code?
Correction: I use C++ in my embedded code. I limit the C++ features that I use to those that I believe are appropriate to the embedded system that I am implementing.
> Which processors?
Mostly PowerPC, ARM and MIPS.
> Whats you opinion on EC++?
EC++ is an obsolete crutch. For example, the exclusion of templates is, IMHO, an arbitrary rule. Templates (like many other features) are a tool that can be used appropriately or abused. There is no substitute for knowing/understanding the purpose and effects of a tool, and then using the appropriate tool for the job.
> Could you please elaborate on the usage of GCC on the > EC++ respect?
What else do I need to say?
> I don't expect code to be optimized but should be at > least equivalent to plain C.
Why would you not expect optimization?
> I want to use power of C and modular, not structural, > pattern of C++.
I honestly don't understand what you are asking. Probably your best teacher here would be to code an equivalent application in each language using the features that you require and study the resulting output of the toolchain. This is a step in understanding your tools. -- Michael N. Moran (h) 770 516 7918 5009 Old Field Ct. (c) 678 521 5460 Kennesaw, GA, USA 30144 http://mnmoran.org "So often times it happens, that we live our lives in chains and we never even know we have the key." "Already Gone" by Jack Tempchin (recorded by The Eagles) The Beatles were wrong: 1 & 1 & 1 is 1
Chris Hills wrote:
> In article <GGmri.10446$ae7.3602@bignews7.bellsouth.net>, Michael N. > Moran <mnmoran@bellsouth.net> writes >> Chris Hills wrote: >>> C++ isn't modular but C is. >> >> I hope you'll forgive me, but will you >> please elaborate on this claim? > > A little facetious but C is modular and C++ OO :-) > > You can do quite good OO programming in C too though both quite the same > as there is no inheritance. > > It seemed the OP had the answer before asking the question. He had > chosen C++ regardless of how appropriate it was and would damned well > make it fit. > >
No, I didn't have the answer. EC++ was on my mind but I was looking for good arguments to deny its use. Everybody has its own arguments but I found that nobody actually uses the standards of EC++. You are more experienced guys. So I would crap my idea of using EC++ or C++ for that matter because I need to run on 8-bitters. --Himanshu
Michael N. Moran wrote:
> Himanshu Chauhan wrote:
> >> Could you please elaborate on the usage of GCC on the >> EC++ respect? > > What else do I need to say? > >> I don't expect code to be optimized but should be at >> least equivalent to plain C. > > Why would you not expect optimization? >
By optimized code I meant the code that would be produced by a C compiler rather than C++ compiler. Wouldn't there be any difference between the two?
>> I want to use power of C and modular, not structural, >> pattern of C++. > > I honestly don't understand what you are asking. > Probably your best teacher here would be to code > an equivalent application in each language using > the features that you require and study the > resulting output of the toolchain. >
I meant I wanted to use basic OOPs features like classes and inheritance etc. with the flexibility and portability of C. --Himanshu