Sign In
Forgot Password?
Sign In | | Create Account

C++ - more Questions and Answers

Colin Walls

Colin Walls

Posted Jun 16, 2014
0 Comments

Following on from my recent online C++ lecture series, I found that I had a lot of interesting questions from the audience, which I had limited time to answer. It seemed logical to do so here. So this is the first of a number of posts where I will address one or more of these questions. If you have any questions about embedded software [not just C++], please email me and I will do my best to answer them.

For today, there are just 3 C++ related queries …

For what kind of embedded applications is C++ suitable?

Given the availability of suitable tools for the chosen target, almost any application could be efficiently coded in C++, as there should be no more overhead than doing the job in C. However, the true benefits of using the C++ language are more apparent in a larger project, where there may be significant number of developers working on the code.

Does “mangling” occur after compiling?

This question refers to the process whereby C++ function names are modified in order to make them unique with respect to the number and type of the parameters. This facilitates function overloading and typesafe linkage, where the link will give an error if the definition/declarations and usage of a function do not match across translation units.

To answer the question: No, mangling occurs during compilation as the compiler builds the symbol table. As all functions must be prototyped in C++, it is when the prototypes are read that the compiler creates the mangled name. As it finds calls to functions, their names are mangled and the absence of a matching prototype results in a compile time error.

Are all C keywords recognized by C++?

The simple answer to this question is: kind of yes. As the two languages are developing in a somewhat independent manner, this may not always be the case. It should not matter to a specific developer, as they should have a thorough grasp of the dialect of the language they are using. It is important to use a naming convention for variables, constants, classes etc. which is not simply lower case letters, thus avoiding any possible clash with keywords. One particularly interesting example is the keyword auto, where it means something entirely different between the two languages.

I acknowledge input from my colleague Jon Roelofs who put me right on a few points.

More Blog Posts

About Colin Walls Follow on Twitter

Colin WallsI have over twenty-five years experience in the electronics industry, largely dedicated to embedded software. A frequent presenter at conferences and seminars and author of numerous technical articles and two books on embedded software, I am a member of the marketing team of the Mentor Graphics Embedded Systems Division, and am based in the UK. Away from work, I have a wide range of interests including photography and trying to point my two daughters in the right direction in life. Learn more about Colin, including his go-to karaoke song and the best parts of being British: http://go.mentor.com/3_acv Visit The Colin Walls Blog

More Posts by Colin Walls

Comments

No one has commented yet on this post. Be the first to comment below.

Add Your Comment

Please complete the following information to comment or sign in.

(Your email will not be published)

Archives

 
Online Chat