C source migration to CPP

K

karunesh

hi there,

we have a product which is written fully in c. now i have to migrate
this source to cpp.
as some of our client want our Libs in cpp. so can you help me what
step will be Evolve.

our tool is Graphics SDK which gives facility to design you GUI at
desktop side and then this write c code of the same and there is target
side code which contain the definitions of those source. it work on
different Embedded platform.

now question is what step should we take so that we can support both c
and cpp.

we are even ready to write the whole SDK from scratch.

Please through some light .

Regards,
Karunesh
 
R

Roland Pibinger

we have a product which is written fully in c. now i have to migrate
this source to cpp.
as some of our client want our Libs in cpp. so can you help me what
step will be Evolve.

C++ is almost a superset of C. Just compile your source with a C++
compiler and correct the errors. Especially you need to cast the
return value of *alloc and rename identifiers that are reserved words
in C++ (e.g. new, delete, class, ...).
now question is what step should we take so that we can support both c
and cpp.

Declare your (exported) functions as extern "C". Then you can use the
compiled library from C and C++, e.g.

#ifdef __cplusplus
extern "C" {
#endif

void foo (int i);
// other functions

#ifdef __cplusplus
}
#endif

Best regards,
Roland Pibinger
 

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

Staff online

Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,052
Latest member
LucyCarper

Latest Threads

Top