When reading some programs, there are always"# Ifdef _ cplusplusExtern "C "{# Endif "to figure out what is going on:
Microsoft-specific predefined macros_ Cplusplus defined for C ++ programs only.It means that if it is a C ++ programExtern "C "{And this stuff refers to the following function does not use the name of C ++, but uses C's
The following code shows a header file which can be used by C and C ++
Client Applications:// Mycfuncs. h# Ifdef _ cpl
1. In many programs, we will encounter the following code segment
# Ifdef _ cplusplusExtern "C "{# Endif
// C syntax code segment
# Ifdef _ cplusplus}# Endif //
First, we should know that __cplusplus is a custom macro in CPP, which indicates that this is a piece of CPP Code. The Compiler compiles the system in C ++ mode .. If we need to use the C language code at this time, we need to add the (extern "C" {) Section to explain, or the compiler will com
Often in CPPCodeSee this code in:
# Ifdef _ cplusplusExtern "C "{# Endif
// A piece of code
# Ifdef _ cplusplus}# Endif
What does this code mean? First, _ cplusplus is the reserved macro definition of the C ++ compiler. That is to say, the C ++ compiler considers this macro has been defined. If this macro is defined, it indicates that this is a piece of CPP Code.
That is to say,
The above code i
The following code is often seen in the CPP Code:
# Ifdef _ cplusplusExtern "C "{# Endif
// A piece of code
# Ifdef _ cplusplus}# Endif
What does this code mean? First, __cplusplus is the custom macro in CPP. If this macro is defined, it indicates that this is a piece of CPP Code. That is to say, the above Code indicates: if this is a piece of CPP Code, add extern "C" {And} to process the code.
To understand why extern "C" is used, you must start wi
# Ifdef _ cplusplus, which is generally used to Output C ++ code in the form of standard C (called in the form of C ), this is because C ++ is often considered as a superset of C, but the C ++ compiler is still different from the C compiler. It is safe to call the code in C ++ in C. Generally, cross-platform usage is considered as follows: # ifdefined (_ cplusplus) | defined (c_plusplus) // cross-platform d
Zcelib-one cplusplus C + + Crossplatform library use for develop server,similar to ACE.OS adaptation layer, in order to adapt to the Windows and Linux two environments code added layer, while there are some extensions, basically can replace ACE. This part actually uses a lot of interesting code, the main idea is to simulate POSIX code under Windows. Let my code be debugged directly under Windows. This part of the code is named after the beginning of z
Cplusplus Library online management; similar to Python's pip install, Nodejs NPM moduleAnd Apache's often-used Apache Ivy project relies on management tools/maven this kind ofThere seems to be no dedicated community of C + + in this area.If the C + + code can be like this, like the Java class Library, free to spread, easy to download to the local, use, then what a pleasant thing?I would love to do such a thing! Build a C + + online code base and manag
The following code is often seen in the CPP Code:
# Ifdef_ CplusplusExtern "C "{# Endif
// A piece of code
# Ifdef_ Cplusplus}# EndifWhat does this code mean? First,_ CplusplusIt is a custom macro in CPP. If this macro is defined, it indicates that this is a piece of CPP Code, that is, the meaning of the above Code is: if this is a piece of CPP Code, add extern "C" {And} to process the code.
To understand why extern "C" is used, you must start with th
the KEY.If we need a dictionary sorted by value , it can be done in the following way:(1) the following values are sorted in order of value from large to Small.DIC = {'a': 31,'BC'75A'C': 3,'ASD': 4,'AA': 74,'D': 0} #dic. iteritems () gets a list of [(keys, values)]. #然后用sorted方法, by the key parameter, specifies that the sort is sorted by value, or 2nd element d[1]. Reverse = True indicates that it needs to be flipped, the default is small to large, flip the words, that is, from large to Small.
The following code is often seen in the CPP Code:
1 # ifdef _ cplusplus2 extern "C" {// Why is there a # endif in the brackets first and # ifdef _ cplusplus in the end ???3 # endif // 1st rows correspond to 3rd rows, and 5th rows correspond to 7th rows
4 // a piece of code // {} indicates that all the values in the brackets are compatible with the C functions. If there are no parentheses, extern C only modifies the following sentence.
5 # ifdef _ cplu
The following code is often seen in the CPP Code:
# Ifdef _ cplusplusExtern "C "{# Endif
// A piece of code
# Ifdef _ cplusplus}# EndifWhat does this code mean? First, __cplusplus is the custom macro in CPP. If this macro is defined, it indicates that this is a piece of CPP Code. That is to say, the above Code indicates: if this is a piece of CPP Code, add extern "C" {And} to process the code.
To understand why extern "C" is used, you must start with
The following code is often seen in the CPP Code:
# Ifdef _ cplusplusExtern "C "{# Endif
// A piece of code
# Ifdef _ cplusplus}# EndifWhat does this code mean? First, __cplusplus is the custom macro in CPP. If this macro is defined, it indicates that this is a piece of CPP Code. That is to say, the above Code indicates: if this is a piece of CPP Code, add extern "C" {And} to process the code.
To understand why extern "C" is used, you must start with
(Do not know why the title write C + + always show, should be csdn new Markdown editor Bug) C + + const and C # # can be used to define constants, the two are different, const is a constant with data type, and the macro constant is not, The compiler can perform static type security checks on the former, which is only character substitution and no type safety check.The C language of the Const and C + + is also very different, in C language with the const modified variable is still a variable, ind
Preface
Original translated from simplified.
In C ++, convert a known type to another type. We call it type conversion. This article will introduce various types of conversion in C ++.
Implicit conversion
Implicit conversion does not require any
(Do not know why the title write C + + always does not appear, should be csdn new Markdown editor Bug) C + + const and C language #define can be used to define constants, the two are different, const is a constant of data types, and macro constants
++ code calls C language code
2. Use it in the header file of C ++
3. Some people may be good at C language and some others are good at C ++ in collaborative development, which will be used in this case.
Here is an example of my design:
ModuleA and moduleB are two modules. B calls the code in A, where A is implemented in C language and B is implemented in C ++. The following provides an implementation method:
// ModuleA header file
# Ifndef _ MODULE_A_H // For module A, this macro is used to pr
header file of C ++
3. Some people may be good at C language and some others are good at C ++ in collaborative development, which will be used in this case.
Here is an example of my design:
Modulea and moduleb are two modules. B calls the code in a, where A is implemented in C language and B is implemented in C ++. The following provides an implementation method:
// Modulea header file
# Ifndef _ module_a_h // For module A, this macro is used to prevent repeated references to header files.
# DE
Share new users and authorization methods in Mysql, and authorize mysql
In the project development process, you may need to open your own database to others, but to ensure security, you cannot open other databases on your server at the same time. You can create a new user and grant the user specific database permissions.
Test environment: Centos 6.3 and Mysql 5.3
1. Create a user
Copy codeThe Code is as follows:// Log on to MYSQL@> Mysql-u root-p@> Password// Create a userMysql> insert into mysq
Test environment: Centos 6.3 and MySQL 5.3First, the new userLog in to MySQL@>mysql-u root-p@> PasswordCreate usermysql> INSERT INTO Mysql.user (Host,user,password) VALUES ("localhost", "Cplusplus", Password ("cplusplus.me"));Refresh System Permissions TableMysql>flush privileges;This creates a user named: cplusplus Password: cplusplus.me.Second, the login testmysql>exit;@>mysql-u
LinuxC calls the C ++ library-general Linux technology-Linux programming and kernel information. The following is a detailed description. C calls the C ++ function library. Generally, it cannot be called directly. You need to convert the C ++ library into the C interface output. You can use the C call. See the following example:
Aa. cxx
# Include "add. h"
Int sample: method ()
{
Cout }
Aa. h
# Include
Using namespace std;
Class sample
{
Public:
Int method ();
};
Place the above two
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.