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

C³ÌÐòµ÷ÓÃC++º¯Êý

ÕâÖÖÐèÇóÓ¦¸Ã¾ÍûC++³ÌÐòµ÷ÓÃCº¯ÊýÐèÇó¶àÁË.ĿǰµÄʵÏÖ»ù±¾Ö»ÓÐÒ»Àà·½·¨,¼´Í¨¹ý´¦Àí±»µ÷ÓõÄC++Îļþ.
ÎÄ
Öиø³öµÄÈÔÈ»ÊÇÍêÕûµÄ,¾ßÌåµÄ,µ«ÓÖ×î»ù±¾×î¼òµ¥µÄʵÏÖ,ÖÁÓÚÀíÂÛÐԵĶ«Î÷ÔÚÍøÉϺÜÈÝÒ×ËÑË÷µÄµ½.ÕâÀïÊÇÕë¶Ôµ÷ÓÃC++µÄ³ÉÔ±º¯ÊýµÄʵÏÖ.
aa.h
class AA {
    int i;
    public:
        int ThisIsTest(int a, int b); 
        float ThisIsTest(float a, float b);
};
extern "C" int ThisIsTest_C(void* s, int a,int b);
extern "C" float PolymorphicTest_C(void* s,float a, float b);
aa.cpp:
#include "aa.h"
int AA::ThisIsTest(int a, int b){
    return (a + b);
}
float AA::PolymorphicTest(float a, float b){
    return (a+b);
}
int ThisIsTest_C(void* s, int a,int b){
    AA* p = (AA*)s;
    return p->ThisIsTest(a,b);
}
float PolymorphicTest_C(void* s,float a, float b){
    AA* p = (AA*)s;
    return p->ThisIsTest(a,b);
}
a.h:
#ifndef __A_H
#define __A_H
int bar(void* s,int a, int b);
int bar_float(void* s,float a, float b);
#endif
a.c
#include <stdio.h>
#include "a.h"
extern int ThisIsTest_C(void* s, int a,int b);
extern float PolymorphicTest_C(void* s,float a, float b);
int bar(void* s,int a, int b) {
  printf("result=%d\n", ThisIsTest_C(s,a, b));
  return 0;
}
int bar_float(void* s,float a, float b) {
  printf("result=%f\n", PolymorphicTest_C(s,a, b));
  return 0;

main.c:
#include "a.h"
struct S {
  int i;
};
struct S s;
int main(int argc, char **argv){
  int a = 1;
  int b = 2;
  float c = 1.5;
  float d = 1.4;
  bar((void*)&s,a, b);
  bar_float((void*)&s,c,d);
  return(0);
}
Makefile:
all:
    gcc -Wall -c a.c -o a.o
    gcc -Wall -c aa.cpp -o aa.o
    gcc -Wall -c main.c -o main.o
 


Ïà¹ØÎĵµ£º

ÓÃCдµÄ3DÃÔ¹¬

          Boss˵£¬Òª¿´OpenGL£¬¿´ÁË¿ìÒ»¸öÔ£¬×ÜËã³öÁ˸öÏñÑùµÄ¶«Î÷£¬ÓÃCдÁ˸ö3DÃÔ¹¬£¬
ËäȻֻÓÐ350ÐÐ
       ´úÂ룬²»¹ý±ßѧ±ßд£¬×ã×ãдÁËÒ»ÖÜʱ¼ä£¬»¹ÊÇСÓгɾ͸е쬻î»î»î£¡
         &n ......

Android±àÒë»·¾³(1) ±àÒëNative CµÄhelloworldÄ£¿é

    Android±àÒë»·¾³±¾Éí±È½Ï¸´ÔÓ£¬ÇÒ²»ÏñÆÕͨµÄ±àÒë»·¾³£ºÖ»Óж¥²ãĿ¼Ï²ÅÓÐMakefileÎļþ£¬¶øÆäËûµÄÿ¸öcomponent¶¼Ê¹ÓÃͳһ±ê×¼µÄ
Android.mk.
Android.mkÎļþ±¾ÉíÊDZȽϼòµ¥µÄ£¬²»¹ýËü²¢²»ÊÇÎÒÃÇÊìϤµÄMakefile£¬¶øÊǾ­¹ýÁËAndroid×ÔÉí±àÒëϵͳµÄºÜ¶à´¦Àí£¬Òò´ËÒªÕæÕýÀíÇå
³þÆäÖеÄÁªÏµ»¹±È½Ï¸´ÔÓ£¬² ......

ʹÄãµÄC/C++´úÂëÖ§³ÖUnicode

±¾ÎÄÕª×ÔI18nGuy
Ö÷Ò³µÄһƪÄÚÈÝ£¬Ô­ÎĵØÖ·£ºhttp://www.i18nguy.com/unicode/c-unicode.zh-CN.html
Õâ·ÝÎĵµ¼òÒªµÄ˵Ã÷ÁËÈçºÎÐÞ¸ÄÄãµÄC/C++´úÂëʹ֧֮³ÖUnicode¡£ÔÚÕâÀï²¢²»×¼±¸
½âÊÍÌ«¶àÏà¹ØµÄ¼¼Êõϸ½Ú²¢ÇÒÎҵüٶ¨ÄãÒѾ­»ù±¾ÊìϤMicrosoftÖ§³ÖUnicodeµÄ·½Ê½¡£
ËüµÄÖ÷ҪĿµÄÊÇ·½±ãÄã²éѯÏà¹ØµÄÊý¾ÝÀàÐͺͺ¯Êý£¬ÒÔ¼°ÐÞ ......

¹ØÓÚCµÄ±ä³¤²ÎÊý

ijЩÇé¿öÏÂÏ£Íûº¯ÊýµÄ²ÎÊý¸öÊý¿ÉÒÔ¸ù¾ÝÐèҪȷ¶¨¡£µäÐ͵ÄÀý×ÓÓдó¼ÒÊìϤµÄº¯Êýprintf()¡¢scanf()ºÍϵͳµ÷ÓÃexecl()µÈ¡£ÄÇôËüÃÇÊÇÔõÑùʵÏÖµÄÄØ£¿C±àÒëÆ÷ͨ³£ÌṩÁËһϵÁд¦ÀíÕâÖÖÇé¿öµÄºê£¬ÒÔÆÁ±Î²»Í¬µÄÓ²¼þƽ̨Ôì³ÉµÄ²îÒ죬Ôö¼Ó³ÌÐòµÄ¿ÉÒÆÖ²ÐÔ¡£ÕâЩºê°üÀ¨va_start¡¢ va_argºÍva_endµÈ¡£
²ÉÓÃANSI±ê×¼ÐÎʽʱ£¬²ÎÊý¸öÊý¿É± ......

cÎļþ²Ù×÷£¬¼æÈݶà×Ö½ÚºÍunicode

ÔÚ<TCHAR.h>Í·ÎļþÀÓÐÕâôһ×é²Ù×÷ÎļþµÄºê
       #define _tfdopen    _wfdopen
      
#define _tfsopen    _wfsopen
      
#define _tfopen     _wfope ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ