???????c??c++
???????????? ???????[ 2012/8/7 14:52:44 ] ????????
<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 © 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++?????????????壩??
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11