C++????е?extern "C" {}
???????????? ???????[ 2015/5/22 15:32:42 ] ???????????????
????????????????????????е?
????#ifndef MONGOOSE_HEADER_INCLUDED
????#define MONGOOSE_HEADER_INCLUDED
????/*……………………………*/
????#endif /* MONGOOSE_HEADER_INCLUDED */
??????????????????????MONGOOSE_HEADER_INCLUDED??#ifndef/#endif????????????????????????????ο???mongoose.h???????????????????????MONGOOSE_HEADER_INCLUDED???????????ο???mongoose.h???????MONGOOSE_HEADER_INCLUDED??????????mongoose.h???????????α???????
????2??extern "C"
??????????????????extern "C"???????????????——extern??????"C"????????????????????????extern "C"????塣
????2.1??extern?????
?????????????б?????????????????????????е??????б?????£???????????????????????????????????
????//file1.c:
????int x=1;
????int f(){do something here}
????//file2.c:
????extern int x;
????int f();
????void g(){x=f();}
??????file2.c??g()????x??f()???????file1.c?е??extern????????file2.c??x?????????????????????????????????????x????δ?x?????????????x?????????????????????????????????Σ?????????????????????????????Σ??????????????????£??磺
????//file1.c:
????int x=1;
????int b=1;
????extern c;
????//file2.c:
????int x;// x equals to default of int type 0
????int f();
????extern double b;
????extern int c;
????????δ????д???????????????????
????x????????????
????b???α???????????????
????c???????????Σ??????ж???
???????extern??????extern??C/C++?????б??????????????????÷?Χ????????????????ù????????????????????????????????????????????????????á?????????????????ж??????????????????????????????????????extern?????????磬??????B??????????A?ж?????????????????????????A?????????ɡ??????????B?е??????A?е?????????????Σ????B?????????ú??????????????????????????????д????A???????????????????????????
??????extern??????????? static?????????ε?????????????????????????á?????????????????????????????????????????extern “C”???Ρ?
????2.2??"C"
?????????????C++????????????????д??????????????C++??д???????ο??????????????????д??????С?????????д?????????????????????????????д??????????????????????????磬?????????????????????????????????????????????????????????????治?????
?????????????????????????????extern??????????????????????磬????C??C++???????strcyp()???????????????C???????????????????
????extern "C" char* strcpy(char*??const char*);
?????????????????????????????
????extern char* strcpy(char*??const char*);
??????????????????????????????????strcpy()??
????extern "C"?????????????C??C++????????????extern "C"????е?C????????????????????????????????????C???????C??????????????????κ????????Fortran??assembler???
?????????????????extern "C"??????????????????????????????塣??????????????У??????extern "C"??????????C++???????????????????
???????????????????????????????????????????????????????????????????extern????????????????????"C"?????????????壬???????????????????????
??????????к???????????extern "C"??????????????extern "C"{ }?С?
????2.3??С??extern "C"
????????????????????????????extern "C"???????????????C??C++?????????C++?????е??????????extern "C"??????????????C??????????????????????????????C++??????????????????????C??????п??????C++?????or???????????????????????????C??????????C?????????????????μ??????????
????3??C??C++???????
?????????????extern "C"????????C??C++?????????????????????????C++?е???C?????C?е???C++??????????????C??C++??????????????????????????????????????????extern "C"??????????á?
????3.1??C++??????????
????C++?????????????????????????????????????????????????????????????????????????????????????????????????????????C++??????????????????Щ?????????
????void print(int i);
????void print(char c);
????void print(float f);
????void print(char* s);
???????????
????_print_int
????_print_char
????_print_float
????_pirnt_string
?????????????????????????????????????????????????????????????????????????????????????????print(3)????????????_print_int(3)???????????????????????????????????????????????????????????????????“???????????”??????????????????????????????????“???”??
????C++?е???????????????????????????????g_xx????????????c_xx?????????????????????????????????????
????3.2??C??????????
????C?????в?????????????Щ????????????C++????print(int i)?????????_print_int?????????????_print??????????????C++?е???C???????????????????????C?е?print(3)??????????_print_int(3)?????extern "C"????????????????
????3.3??C++?е???C?????
???????????C??????cHeader.h?а??????????print(int i)???????C++??????????????????????extern???????????extern????????????????????????????£?
????#ifndef C_HEADER
????#define C_HEADER
????extern void print(int i);
????#endif C_HEADER
?????????????????cHeader.c????????
????#include <stdio.h>
????#include "cHeader.h"
????void print(int i)
????{
????printf("cHeader %d "??i);
????}
????????C++????????C++.cpp??????C?е?print(int i)??????
????extern "C"{
????#include "cHeader.h"
????}
????int main(int argc??char** argv)
????{
????print(3);
????return 0;
????}
??????г????????
????image
????3.4??C?е???C++?????
?????????????C?е???C++???????????C++?е???C????????????????????cppHeader.h?????ж?????????????
????#ifndef CPP_HEADER
????#define CPP_HEADER
????extern "C" void print(int i);
????#endif CPP_HEADER
???????????????cppHeader.cpp????д??????£?
????#include "cppHeader.h"
????#include <iostream>
????using namespace std;
????void print(int i)
????{
????cout<<"cppHeader "<<i<<endl;
????}
??????C????????c.c?е???print??????
????extern void print(int i);
????int main(int argc??char** argv)
????{
????print(3);
????return 0;
????}
?????????C?????????????#include "cppHeader.h"?????????????????????????extern int print(int i)???????????
????4??C??C++???????????????????
??????????C??C++?????????????????????????庯?????????????н????????????????????????????????C??C++???????б??????????????????????????????????????????????????????????????????????????????С???????????????????????á?
?????????????????????????????????????????????????????????????????????????????????????????????????????????
????typedef int (*FT) (const void* ??const void*);//style of C++
????extern "C"{
????typedef int (*CFT) (const void*??const void*);//style of C
????void qsort(void* p??size_t n??size_t sz??CFT cmp);//style of C
????}
????void isort(void* p??size_t n??size_t sz??FT cmp);//style of C++
????void xsort(void* p??size_t n??size_t sz??CFT cmp);//style of C
????//style of C
????extern "C" void ysort(void* p??size_t n??size_t sz??FT cmp);
????int compare(const void*??const void*);//style of C++
????extern "C" ccomp(const void*??const void*);//style of C
????void f(char* v??int sz)
????{
????//error??as qsort is style of C
????//but compare is style of C++
????qsort(v??sz??1??&compare);
????qsort(v??sz??1??&ccomp);//ok
????isort(v??sz??1??&compare);//ok
????//error??as isort is style of C++
????//but ccomp is style of C
????isort(v??sz??1??&ccopm);
????}
???????typedef int (*FT) (const void* ??const void*)?????????????????????????FT???????????????????????????????????????int???????????????????????????????????????????void*????
?????????????????????????????????????signal????????????£?
????typedef void (*HANDLER)(int);
????HANDLER signal(int ??HANDLER);
??????????????????????????signal???????????????HANDLER????????????????int??HANDLER?? ???????????????????signal??????
????void (*signal (int ??void(*)(int) ))(int)
?????????????????????typedef??????
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????
??????
??C++????????????C++ lvalue??rvalueC++11????????C++???????????????C++?е?????????????????C++?????????C++???Windows????λ??C/C++???????????????????JAVA??C??C++??????????c++??python???????????????????????????????C++???????C++?е????????C++????????????????C++ ???????????????C++?????????????????????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????????
?????????App Bug???????????????????????Jmeter?????????QC??????APP????????????????app?????е????????jenkins+testng+ant+webdriver??????????????JMeter????HTTP???????Selenium 2.0 WebDriver ??????