开发者

Which would be the easiest way to turn folder with C headers into folder with C++ headers?

I am quite abeginner with all that C/C++ coding. Thay say that having C library with all headers turned into C++ in a fashon like:

   #ifdef __cplusplus 
extern "C" { 
#endif 

//.. header code 

#ifdef __cplusplus 
} 
#endif 

Will make it possibe to esely use practicly any C lib from sources (modified in such way). So I thought I shall give it at least a try. but I found I have like more than 300 headers... Ofcourse I will not use all 开发者_如何学Pythonof them but any way I'd prefere to make job once. So haw can I add such code to all headers? (I work with Windows, VisualStudio 2010 and 2008)


You only really need to do that if you have prebuilt C library code you are trying to interface your C++ code to.

If you still have the sources and are going to build all that C code yourself, you may find it easier to just submit them to the compiler as C++ code. With some compilers it is as simple as renaming the source files to *.cpp.

If that isn't workable, what I'd do is start with what you have, and only bother to put the extern "C" stuff around routines you need to use directly from your C++ code as you find them. That will surely be much less than the full 300 files, right?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜