&nbsp;<SMALL><SMALL>(Part of <A title="C++ FAQ" href="http://www.parashift.com/c++-faq-lite/index.html"><EM>C++ FAQ</EM></A>?? <A title="[1.2] Copyright Notice" href="http://www.parashift.com/c++-faq-lite/copy-permissions.html#faq-1.2">Copyright&nbsp;© 1991-2011</A>?? <A title=www.parashift.com/ href="http://www.parashift.com/" target=_blank>Marshall Cline</A>?? <Atitle=cline@parashift.comhref="mailto:cline@parashift.com"><TT>cline@parashift.com</TT></A>)</SMALL></SMALL><HR>

????1???????c??c++???????????????

?????????г????Щ????????Щ???????????????????????????????????????????

?????? ???????c++??????????main()(?????????????c++??????????)

?????? c++?????????????????link?????????????????????????????????

?????? c??c++???????????????????????????????汾???????????????????ù淶??

???????????????????????????c???????????c++???ú?c++??????????c????

???????????£?????????????????Щ???飺???c++??????????????????????????c????????????????????????????c??c++???????????????????c??????????С??????????????????Щc???????е?bug????????????????????????????????c??????????????c++????????c?????????????????????????????????c???????????????С????c??c++???????????????????????????????????????????c?????????????????????????c?????????磬??????????????????????????????????????

????2?????????c++?????а?????include??c????????

??????????????????????????<cstdio>????????????κ?????????飺


// This is C++ code
 
 #include <cstdio>                // Nothing unusual in #include line
 
 int main()
 {
   std::printf("Hello world ");  // Nothing unusual in the call either
   ...
 }


????????????std::printf()?е?std::??????????????????“???”???????仰????????????????????????????????????????????????????

??????????????????c++??????????c??????????????????printf()???std::printf()????????????????????c??????t????????<stdio.h>?????????·???????<cstdio>??namespace?????????????????飺


 /* This is C code that I'm compiling using a C++ compiler */
 
 #include <stdio.h>          /* Nothing unusual in #include line */
 
 int main()
 {
   printf("Hello world ");  /* Nothing unusual in the call either */
   ...
 }


????????????飬??????c???????????????????в??????顣?????????????????????????????????????????

????3?????????c++?????а?????include????????c????

?????????????????????????????c??????????????????#include?а?????extern "C" { /* ... */}???С???????c++????????????????????????????c??????


// This is C++ code
 
 extern "C" {
   // Get declaration for f(int i?? char c?? float x)
   #include "my-C-code.h"
 }
 
 int main()
 {
   f(7?? 'x'?? 3.14);   // Note: nothing unusual in the call
   ...
 }
????4???????????????????c??????????????????????c++??????

?????????????????????????????c????????????????????c?????????????????????????extern "C" {...}??????????c++?????????c++?????С????c???????????extern "C"????????????extern "C"??????#ifdef?????????????????c????????????

??????????????????з??c??????????????????__cplusplus???????????????c++?????????????壩??