0

I am using CppUTest in eclipse-cdt(ubuntu 14.0). For inherits of C function in CppUTest I should write,

extern "C" {
}

Is any alternative to inherit all C project into Cpp for CppUTest ?

What is the disadvantages of extern in CppUTest?

Ravi
  • 13
  • 1
  • 7

1 Answers1

0

Well, one "alternative" is of course to move the extern "C" declarations into your C-project's headers, protected by #if defined __cplusplus of course. That will, however, mean that you have to go through the entire project and fix it. It sounds as if just doing the above in your test code, which is where you're using C++, would be easier.

Many people do that, as a way to make their C code usable from C++. Personally I think it's a bit "dirty", since you're mixing languages ("don't cross the streams!"), but it's still very common.

See this question for lots of discussion about this.

Community
  • 1
  • 1
unwind
  • 391,730
  • 64
  • 469
  • 606