Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

extern "C" Ïê½â

 extern "C" Ïê½â
ÔÚC++ÖУ¬ÎªÁËÖ§³ÖÖØÔØ»úÖÆ£¬ÔÚ±àÒëÉú³É»ã±à´úÂëʱ£¬º¯ÊýµÄÃû×ÖÒª¼ÓÈ뺯ÊýµÄ²ÎÊýÀàÐÍ»òÕß·µ»ØÖµÀàÐ͵ÈÐÅÏ¢
ÔÚCÖУ¬ÒòûÓÐÖØÔØ»úÖÆ£¬±àÒëºóµÄ´úÂëÖ»ÊǼòµ¥µÄº¯ÊýÃû×Ö¶øÒÑ£¬²»¼ÓÈëÆäËûµÄÐÅÏ¢ 
1. ²»¼ÓÈëextern "C"
testexternc.cpp
int mytest(void)
{
int a=10,b=20;
int c=a+b;
return c;
}
 
 
Command: g++ -S testexternc.cpp»òÕßgcc -S testexternc.cpp
Generated file: testexternc.s
        .file        "testexternc.cpp"
        .text
        .align 2
.globl _Z6mytestv
        .type        _Z6mytestv, @function
_Z6mytestv:
.LFB2:
        pushl        %ebp
.LCFI0:
        movl        %esp, %ebp
.LCFI1:
        subl        $16, %esp
.LCFI2:
        movl        $10, -12(%ebp)
        movl        $20, -8(%ebp)
        movl        -8(%ebp), %eax
        addl        -12(%ebp), %eax
        movl        %eax, -4(%ebp)
        movl        -4(%ebp), %eax
        leave
        ret
.LFE2:
        .size        _Z6mytestv, .-_Z6mytestv
.globl __gxx_personality_v0


Ïà¹ØÎĵµ£º

C/C++——С±à̸CÓïÑÔº¯ÊýÄÇЩÊÂ(22)

C³ÌÐòÊÇÓÉÒ»×é»òÊDZäÁ¿»òÊǺ¯ÊýµÄÍⲿ¶ÔÏó×é³ÉµÄ¡£ º¯ÊýÊÇÒ»¸ö×ÔÎÒ°üº¬µÄÍê³ÉÒ»¶¨Ïà¹Ø¹¦ÄܵÄÖ´ÐдúÂë¶Î¡£ÏÂÃæС±àºÍ´ó¼Ò·ÖÏíÏÂCÓïÑÔÖеĺ¯Êý¡£
 
1.    setmemº¯Êý
setmemº¯ÊýµÄ¹¦ÄÜÊÇ´æÖµµ½´æ´¢Çø£¬ÆäÓ÷¨Îª£ºvoid setmem(void *addr, int len, char value);³ÌÐòʵÀýÈçÏ£º
#include <stdio.h& ......

C/C++——С±à̸CÓïÑÔº¯ÊýÄÇЩÊÂ(26)

C³ÌÐòÊÇÓÉÒ»×é»òÊDZäÁ¿»òÊǺ¯ÊýµÄÍⲿ¶ÔÏó×é³ÉµÄ¡£ º¯ÊýÊÇÒ»¸ö×ÔÎÒ°üº¬µÄÍê³ÉÒ»¶¨Ïà¹Ø¹¦ÄܵÄÖ´ÐдúÂë¶Î¡£ÏÂÃæС±àºÍ´ó¼Ò·ÖÏíÏÂCÓïÑÔÖеĺ¯Êý¡£
 
1.   sopenº¯Êý
sopenº¯ÊýµÄ¹¦ÄÜÊÇ´ò¿ªÒ»¹²ÏíÎļþ£¬ÆäÓ÷¨Îª£ºint sopen(char *pathname, int access, int shflag, int permiss);³ÌÐòʵÀýÈçÏ£º
#include ......

C/C++Ì⼯

ת×Ô£º http://hi.baidu.com/elliott_hdu/blog/item/411421dd5bf8dfe977c63876.html
1.ÏÂÁгÌÐòµÄÊä³ö½á¹ûΪ£º(B)
#include<iostream.h>
void main()
{
       char* a[ ] = { "hello", "the", "world"};
       char** pa = a;
 &nbs ......

c»ñµÃÎļþ´óС

 1.MFCÖеķ½·¨£º(C++)
CFileStatus status;
CFile::GetStatus("D:\\test.txt",status);
long lSizeOfFile;
lSizeOfFile = status.m_size;
lSizeOfFileµÄÖµ¾ÍÊÇD:\\test.txtÎļþµÄ´óС
2.±ê×¼C»ñµÃÎļþ´óСµÄ5ÖÖ·½·¨
(×¢Ò⣺"__FILE__"Ö¸µÄÊǵ±Ç°Îļþ£¬Äã¿ÉÒÔ¸ÄΪÓÐЧ·¾¶µÄÄ¿±êÎļþ£¬±ÈÈç"D:\\test.txt"£©
#i ......

C´æ´¢ÀàÐͼ°¾²Ì¬¡¢´æ´¢ÀàÐÍÑó½â

 CµÄËÄÖÖ´æ´¢ÀàÏÞ¶¨·û£º
extern:Íⲿ±äÁ¿
static £º¾²Ì¬
register£º´æ´¢Æ÷
auto£º×Ô¶¯¡¡
¾²Ì¬¾Ö²¿±äÁ¿£º
´æ´¢ÇøºÍÈ«¾Ö±äÁ¿ÊÇÒ»ÑùµÄ¡£¾²Ì¬¾Ö²¿ºÍÈ«¾Ö±äÁ¿¼äµÄÖ÷ÒªÇø±ðÊÇ£º¾²Ì¬¾Ö²¿±äÁ¿½ö¶ÔËüÔÚÆäÖÐÉùÃ÷µÄ¿éÊÇ¿ÉÖªµÄ¡£
¾²Ì¬È«¾Ö±äÁ¿£º
¸æËß±àÒëÆ÷´´½¨Ò»¸ö½öÔÚÉùÃ÷ËüµÄÎļþÖпÉÖªµÄÈ«¾Ö±äÁ¿¡£ÕâÒâζ×Å£º¼´Ê¹±äÁ¿Ê ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ