Say I have the following C++ code:
int x;
some_class y;
extern "C" {
void foo () {
// do something with x
// do something with y
}
}
Do x and/or y need to be declared with extern "C"?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No. There is no restriction on
extern "C"functions accessing functions and variables with C++ language linkage.C++
extern "C"functions are often used to provide a C interface into code with C++ language linkage so it would be more than a little restrictive if this were the case.