Effective Use of Low-Level C and C++

M

Matt Priest

I am trying to learn more about how to effectively mix low-level C code
with C++. I am having trouble finding resources/papers/books that
aren't in one or the other camp exclusively.

Can anyone point me toward a good place to start? I want to understand
how to make decisions about the development environment, code structure
and planning, and any other issues that I'm not aware of that may be
important to know.

Thanks in advance!

Matt
 
V

Victor Bazarov

Matt Priest said:
I am trying to learn more about how to effectively mix low-level C code
with C++. I am having trouble finding resources/papers/books that
aren't in one or the other camp exclusively.

Shouldn't that serve as a hint for you?
Can anyone point me toward a good place to start?

You should probably start with a decent C++ book.
I want to understand
how to make decisions about the development environment, code structure
and planning, and any other issues that I'm not aware of that may be
important to know.

This has nothing to do with either language. Visit comp.software-eng.

Victor
 
G

Gianni Mariani

Victor said:
Shouldn't that serve as a hint for you?




You should probably start with a decent C++ book.




This has nothing to do with either language. Visit comp.software-eng.

Victor's comment is 100% right but that is not the perception I hear
from embedded and low level engineers.

There are 2 factors that confound the issue for C++. The first is
complexity. C++ is far more complex than C and while the run-time
implications of C++ are miniscule and often far more favorable than C,
however the "programmer insecurity" factor kicks in and most engineers
don't leave themselves the time luxury to learn C++. The second factor
is the STL. The STL has some very cool features, however it is not
effective for the embedded paradigm where space and resource utilization
is a major issue. In some cases, real-time (also regulatory) contraints
preclude the use of the STL.

Every discussion I have had with an anti-C++ embedded programmer, I have
been able to give constructive discussion about how moderm compilers and
C++ have an excellent synergy and got them thinking about the
possibilities (or I just bored them to submission, I have yet to find out).

There are a couple of meanings to "low level" - 1. kernel and driver
code and 2. embedded code. The constraints are very similar.
Performance and resource utilization constraints are more significant
that application code. Also, most low level code needs to run for much
longer periods and the consequences of code failure is far more
significant. (e.g. my cell phone crashes ... it's true ...).

Significant factors for embedded apps:

1. code size (limited ROM space)
2. stability (*must* never crash)
3. real-time (if a coms interrupt is not serviced, data is lost)

These are more design issues than language issues. However C++ does
have some very nice tools to be able to achieve these 3 that C does not.
C++ templates allow you to create very efficient "policy" objects that
allow you to create very stable and much easier to maintain code.
Inlining small methods increses performance and may actually reduce code
size.

OK - I'm done with the ranting ... for now.
 
S

stephan beal

Matt said:
I am trying to learn more about how to effectively mix low-level C code
with C++. I am having trouble finding resources/papers/books that
aren't in one or the other camp exclusively.

Can anyone point me toward a good place to start? I want to understand
how to make decisions about the development environment, code structure
and planning, and any other issues that I'm not aware of that may be
important to know.

Scott Meyers' "More Effective C++", Item #34, is a good starting point.

--
----- stephan beal
Registered Linux User #71917 http://counter.li.org
I speak for myself, not my employer. Contents may
be hot. Slippery when wet. Reading disclaimers makes
you go blind. Writing them is worse. You have been Warned.
 
T

Thomas Matthews

Matt said:
I am trying to learn more about how to effectively mix low-level C code
with C++. I am having trouble finding resources/papers/books that
aren't in one or the other camp exclusively.

I really don't understand how the "low-level" C code differs from
the "low-level" C++ code, unless we have a different understanding
of "low-level code".

My understanding of "low-level" language code is the statements that
allow bit manipulation. Both languages have the same capabilities
for bit manipulation.

My 20+ years of experience with embedded systems has shown me that
both C and C++ can be used to access hardware components directly.
In systems where the components are memory mapped, deferencing a
pointer will access the hardware component.

Can anyone point me toward a good place to start?

Start doing what? Programming an embedded system? Accessing hardware
components? Bit manipulations? Writing your operating system?

I want to understand
how to make decisions about the development environment, code structure
and planning, and any other issues that I'm not aware of that may be
important to know.

I believe most of your issues can be answered by the folks at
Thanks in advance!

Matt


--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,045
Latest member
DRCM

Latest Threads

Top