Quick Search


Tibetan singing bowl music,sound healing, remove negative energy.

528hz solfreggio music -  Attract Wealth and Abundance, Manifest Money and Increase Luck



 
Your forum announcement here!

  Free Advertising Forums | Free Advertising Board | Post Free Ads Forum | Free Advertising Forums Directory | Best Free Advertising Methods | Advertising Forums > Post Your Free Ads Here in English for Advertising .Adult and gambling websites NOT accepted. > Business to Business Ads:

Business to Business Ads: This forum is for posting ads that would be of interest to other Business Owners. Things like Marketing Services, Supply Services, and Business Essentials.

Reply
 
Thread Tools Display Modes
Old 03-24-2011, 06:21 AM   #1
powerband6i
Private First Class
 
Join Date: Mar 2011
Posts: 25
powerband6i is on a distinguished road
Default power balance bracelet C + + project in extern C {

# ifndef MONGOOSE_HEADER_INCLUDED
# define MONGOOSE_HEADER_INCLUDED
/ * ... ... ... ... ... ... ... ... ... ... ... * /
# endif / * MONGOOSE_HEADER_INCLUDED * /
specify a function pointer and when the compilation and connection, the function of all types, including function name, function, variables are also introduced in the manner specified by compiling and linking. The following example:
4, C and C + + mixed-called special function pointer
3.3, C + + code to call C
view sourceprint? 1 # ifdef __cplusplus2extern ; 5 /*...*/ 6 7 # ifdef __cplusplus8} 9 # endif
view sourceprint? 1typedef void (* HANDLER) (int); 2HANDLER signal (int, HANDLER);
to play a role. If you define MONGOOSE_HEADER_INCLUDED, # ifndef / # endif is ignored between the contents of the swap. Therefore, the first compilation
Time to see mongoose.h header file, its contents will be read and given MONGOOSE_HEADER_INCLUDED a value. Again after seeing mongoose.h
The first file, MONGOOSE_HEADER_INCLUDED already defined,power balance bracelet, mongoose.h content will not be read again.
attention to the code in the C file directly # include And if not extern int print (int i) compile mistakes.
x is defined twice been declared twice b for different types of c is declared twice, but does not define
extern Note: extern C that meet the C language, compile and link the statute any language, such as Fortran, assembler and so on.
back extern keyword, extern is the C / C + + language for that functions and global variables
With the range (visibility) of the keyword to tell the compiler, and its functions and variables declared in the module or can be used in other modules. Usually, the first file in the module on the module to other modules referenced
Functions and global variables declared with the keyword extern. For example, if module A module B For reference the defined global variables and functions need only contain the module A header files. This module is called module B
A function in the compilation stage, although not find the function module B, but not an error; it will phase in the connection from the module A compiled object code to find this function.
1, # ifdef _cplusplus / # endif _cplusplus and divergent 2, extern , C call C + + code 4, C and C + + mixed-called special function pointer 1, # ifdef _cplusplus / # endif _cplusplus and divergent
view sourceprint? 1extern 4 5int main (int argc, char ** argv) 6 {7 print (3); 8 return 0; 9}
Introduction
view sourceprint ? 01 # ifndef MONGOOSE_HEADER_INCLUDED02 # define MONGOOSE_HEADER_INCLUDED03 04 # ifdef __cplusplus05extern .................. 09 * do something here10 *........................ ......... 11 * / 12 13 # ifdef __cplusplus14} 15 # endif / * __cplusplus * / 16 17 # endif / * MONGOOSE_HEADER_INCLUDED * /
In this code, there are three such errors:
3.4, C call C + + code in C
view sourceprint? 1 # include 2 # include i); 6}

view sourceprint? 1extern char * strcpy (char *, const char *);
view sourceprint? 01typedef int (* FT) (const void *, const void *);// style of C + +02 03extern (* CFT) (const void *, const void *);// style of C05 void qsort (void * p, size_t n, size_t sz, CFT cmp); / / style of C06} 07 ; 08void isort (void * p, size_t n, size_t sz, FT cmp); / / style of C + +09 void xsort (void * p, size_t n, size_t sz, CFT cmp); / / style of C10 11 / / style of C12extern (const void *, const void *);// style of C16 17void f (char * v, int sz) 18 {19 / / error, as qsort is style of C20 ; / / but compare is style of C + +21 qsort (v, sz, 1, & compare); 22 qsort (v, sz, 1, & ccomp); / / ok23 24 isort (v, sz, 1, & compare); / / ok25 / / error, as isort is style of C + +26 / / but ccomp is style of C27 isort (v, sz, 1, & ccopm); 28}
in a project must ensure that the functions, variables, enumerations, and other source files in all consistent, unless you specify is defined as local. First, let an example:
here Why do I need # ifdef _cplusplus / # endif _cplusplus it? Because the C language does not support the extern In. C file contains extern
assume a C header file cHeader.h contains a function print (int i), C + + in order to be able to call it, must be added extern keyword ( because the section in the extern keyword has been introduced.) Its code is as follows:
C + + variables, the compiler is similar, such as global variables may compile g_xx, class variables compiled c_xx and so on. Connection is also in accordance with this mechanism to find the appropriate variable.
This header mongoose.h may be multiple sources in the project file contains the (# include , the redundancy may lead to error because a header file containing the class definition or inline function in a source file
mongoose.h may be # include two (such as, ah header file contains mongoose.h, and in bc file # include ah and mongoose.h) - This is an error (in the same source file, a structure body, the class is defined twice, etc.). From a logical point of view and reduce compile time, are required to remove the redundancy. However, the programmer to analyze and remove the redundancy, not only tedious and impractical, the most important thing is sometimes in need of such redundancy to ensure the independence of each module.

2, extern Here I interpret these two aspects extern 2.1, extern keyword
letter code above defines the function to signal, its return value type of HANDLER, there are two parameters are int, HANDLER. This avoids the signal function to be defined like this:
now call into C + + code, which is in C + + code to call C is different. As defined in the cppHeader.h header the following code:
view sourceprint? 1extern

view sourceprint? 1 # ifndef C_HEADER2 # define C_HEADER3 4extern void print (int i); 5 6 # endif C_HEADER
look at the following example, in order to declare a variable instead of defining a variable, you must specify the extern keyword in the declaration, but when you then add a ,power bands, but would change its way of compiling and linking.
3.1, C + + compiler and connection
Note: typedef int (* FT) (const void *, const void *), that defines a function pointer alias FT, this function pointer to a function to have such feature: the return value is int type, there are two parameters, parameter type can be any type of pointer (as for the void *).
Now comes the conditions for the compilation, I will introduce one of its important applications - contains the header files to avoid duplication. Remember to test Tencent written about this subject, given the code like the following (below is my recent study of an open source web server - Mongoose mongoose.h in the first section of the code file):
with the corresponding keyword extern is static, it is modified by global variables and functions can only be used in this module. Thus, a function or variable may only be used in this module, which can not be extern
2.2, Similar, C + + code fragment written in other languages ​​may be used in the preparation of the code. Code written in different languages ​​calling each other
Is difficult, or even code written with a different compiler, but code. For example, different languages ​​and different implementations of the same language may be maintained in the registration parameters and the parameters of the variable on the stack layout, this aspect
Not the same.
when we mix C and C + + programming, sometimes the definition of the function pointer in one language, and in the application will function pointer to point to another in language defined functions. If C and C + + to compile and even share the same
Next, the function call mechanism, this is possible. However,power balance bracelet, such a common mechanism, usually assumed that it exists otherwise, so we must be careful to ensure that the expected way function to call.
extern implementation class C and C + + mixed programming. The following describes how we were called in C + + code in C, C call C + + code. First of all to understand each other C and C + + calls, you must know that they compile and link between the differences and how to use extern
C + + is an object-oriented language (although not a pure object-oriented languages), it supports function overloading, override this feature brings us a lot convenience. To support this feature function overloading, C + + compiler will actually override the following functions:
order to enable them to comply with uniform rules, you can use extern to specify a compile and link the Statute. For example, the statement C and C + + standard library function strcyp (), and specify that it should be based on C, compile and link the Statute to the link:
2.3, Summary extern In C + + source file the statement by adding extern This code in the class C can call C + + functions or variables. (Note: I am here to say a class C, on behalf of the C language compiler and with the connections the same in all languages)
3, C and C + + since we know each other call
following this statement, said only when the call is connected strcpy ( .)


If you have a lot of language to add extern
execution output:

attention to its statement with the following differences:
also like to note that, extern For example, in the function declaration, specify the extern

view sourceprint? 1void (* signal (int, void (*) (int))) (int)
Comparisons can clearly appreciate the benefits of typedef.
To solve this problem, the above code
view sourceprint? 1 # ifndef CPP_HEADER2 # define CPP_HEADER3 4extern The implementation file cppHeader.cpp file code is as follows:
view sourceprint? 1 # include ; cout <<i); 2int main (int argc, char ** argv) 3 {4 print (3); 5 return 0; 6}
C language, and class does not override these properties, it is not like C + +, as print (int i), will be compiled into _print_int, but directly compiled _print and so on. So if directly in C + + to call C functions will fail, because the connection is called C in the
print (3), it will go _print_int (3). Therefore extern
What is the use it in the end, you know? Moreover, such problems often appear in the interview or written examination. Here I introduce the following aspects to it:
in file2.c in g () using the x and f () is defined in the file1.c. extern keyword that file2.c in x, just a variable declaration, which does not
In the definition of variable x, not for the x distribution of memory space. Variable x in all modules as a global variable can only be defined once, otherwise there will be a connection error. But can be declared multiple times, and must ensure that the type declaration
Agreement, such as:

introducing the extern ifdef _cplusplus / # endif _cplusplus role. Obviously # ifdef / # endif, # ifndef / # endif for conditional compilation, # ifdef _cplusplus / # endif _cplusplus - said that if the definition of the macro _cplusplus, on the implementation of # ifdef / # endif statements between, or not implementation.
the most typical example of function pointer aliases, the signal processing function signal, which is defined as follows:
implementation file that corresponds to the code for the cHeader.c:
and then tell you that the above macro # ifndef / # endif role? In order to explain a problem, we first look at two facts:
view sourceprint? 1void print (int i); 2void print (char c); 3void print (float f); 4void print (char * s);

now C + + code files C + +. cpp reference C in print (int i) function:
in a project with C + + source code, often the inevitable will see the following code:
view sourceprint? 1_print_int2_print_char3_print_float4_pirnt_string
compiled to:
such a function name, to uniquely identify each function. Note: Different compilers may not implement the same, but are using this mechanism. So when the connection is to call the print (3), it will go to find
_print_int (3) such a function. Here a digression that, precisely because of this, is not considered polymorphic overloading, polymorphism is dynamic binding at run time (To override is a multi-state, which is compiled at the most


view sourceprint? 1 / / file1.c: 2 int x = 1; 3 int b = 1; 4 extern c; 5 / / file2.c: 6 int x; / / x equals to default of int type 07 int f (); 8 ; extern double b; 9 extern int c;
view sourceprint? 1 / / file1.c: 2 int x = 1; 3 int f () {do something here} 4 / / file2.c: 5 extern int x; 6 int f (); 7 void g () {x = f (); }
3.2, C compiler and connection
powerband6i is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 06:26 AM.

 

Powered by vBulletin Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Free Advertising Forums | Free Advertising Message Boards | Post Free Ads Forum