Analysis on the usage of http://www.cnblogs.com/rollenholt/archive/2012/03/20/2409046.htmlextern "C"
1.
IntroductionC ++ language was originally created as "a better C ", however, this does not mean that the compilation and connection methods used
1. Declaring external variables
Modern compilers are generally compiled by file, so at compile time, the global variables defined in each file are
Transparent to each other, that is, at compile time, the visible domain of the global variable is
1. Basic explanationExternIt can be placed before a variable or function to indicate that the definition of a variable or function is in another file, prompting the compiler to find its definition in other modules when it encounters this variable
Const, static, extern usage summary, constextern
Const application:
1. For the basic declaration const int r = 100; // standard const variable declaration and initialization, the compiler will directly replace it with 100 during compilation after
Mutual reference between C and C ++ functions extern "C" for an in-depth understanding
1. Introduction
C ++ language was originally created as "a better C ", however, this does not mean that the compilation and connection methods used by global
1, can local variables and global variable duplicate?
A: Yes, the local will screen the overall situation. To use a global variable, you need to use the "::"
Local variables can have the same name as global variables, and when referenced within a
The original intention of the C ++ language is "a betterC. as a language compatible with C, C ++ retains a part of the processStyle language features (known as "not completely Ground Object"), so it can define global variables and functions that do
First, let's take a look at the definition of Baidu:
Extern "C" contains a double meaning, which can be obtained literally: first, the target is "extern", and second, the target is "C. Let's explain these two meanings in detail.
(1) functions or
Recently learning Lua, about LUA compiled place, because Lua is written in C, C language in C + + functions, need to use the extern "C" compile before, seemingly did not touch this knowledge, write a blog to commemorate, by the way the role of the
assuming the C + + library file is libtest.a and the header file of the library is test.h, write this in test.h: Before and after the function to be exported: extern "C" {void Test_func ();.} &nbs p; then use g++ to compile the source file of
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.