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

C/C++ ×Ö½Ú¶ÔÆëÎÊÌâ

VCÖÐÏÂÃ漸¸ö½á¹¹Ìå´óС·Ö±ðÊǶàÉÙÄØ
struct MyStruct
{
    double m4;
    char m1;
    int m3£»
};
struct MyStruct {
    char m1;
    double m4;
    int m3;
};
#pragma pack(push)   //±£´æ¶ÔÆë״̬
#pragma pack(16)      //ÉèÖÃΪ16×Ö½Ú¶ÔÆë
struct test
{
   char m1;
   int m3;
   double m4;    
};
#pragma pack(pop)//»Ö¸´¶ÔÆë״̬
Èç¹ûÄãµÄ´ð°¸²»ÊÇ16£¬24ºÍ16£¬ÏàÐÅÏÂÃæµÄÄÚÈݶÔÄãºÜÓаïÖú¡£
1¡¢sizeofÓ¦ÓÃÔڽṹÉϵÄÇé¿ö
Çë¿´ÏÂÃæµÄ½á¹¹£º
struct MyStruct
{
    double dda1;
    char dda;
    int type
};
¶Ô½á¹¹MyStruct²ÉÓÃsizeof»á³öÏÖʲô½á¹ûÄØ£¿sizeof(MyStruct)Ϊ¶àÉÙÄØ£¿Ò²ÐíÄã»áÕâÑùÇó£º
sizeof(MyStruct)=sizeof(double)+sizeof(char)+sizeof(int)=13
µ«Êǵ±ÔÚVCÖвâÊÔÉÏÃæ½á¹¹µÄ´óСʱ£¬Äã»á·¢ÏÖsizeof(MyStruct)Ϊ16¡£ÄãÖªµÀΪʲôÔÚVCÖлáµÃ³öÕâÑùÒ»¸ö½á¹ûÂð£¿
Æäʵ£¬ÕâÊÇVC¶Ô±äÁ¿´æ´¢µÄÒ»¸öÌØÊâ´¦Àí¡£ÎªÁËÌá¸ßCPUµÄ´æ´¢Ëٶȣ¬VC¶ÔһЩ±äÁ¿µÄÆðʼµØÖ·×öÁË“¶ÔÆë”´¦Àí¡£
        ¢ÙÔÚĬÈÏÇé¿öÏ£¬VC¹æ¶¨½á¹¹Ìå¸÷³ÉÔ±±äÁ¿´æ·ÅµÄÆðʼµØÖ·Ïà¶ÔÓڽṹµÄÆðʼµØÖ·µÄÆ«ÒÆÁ¿±ØÐëΪ¸Ã±äÁ¿µÄÀàÐÍËùÕ¼ÓõÄ×Ö½ÚÊýµÄ±¶Êý¡£
ÏÂÃæÁгö³£ÓÃÀàÐ͵ĶÔÆ뷽ʽ(vc6.0,32λϵͳ)¡£
ÀàÐÍ           ¶ÔÆ뷽ʽ£¨±äÁ¿´æ·ÅµÄÆðʼµØÖ·Ïà¶ÔÓڽṹµÄÆðʼµØÖ·µÄÆ«ÒÆÁ¿£©
Char          Æ«ÒÆÁ¿±ØÐëΪsizeof(char)¼´1µÄ±¶Êý
Short         Æ«ÒÆÁ¿±ØÐëΪsizeof(short)¼´2µÄ±¶Êý
int      Æ«ÒÆÁ¿±ØÐëΪsizeof(int)¼´4µÄ±¶Êý
float Æ«ÒÆÁ¿±ØÐëΪsizeof(float)¼´4µÄ±¶Êý
double Æ«ÒÆÁ¿±ØÐëΪsizeof(double)¼´8µÄ±¶Êý
¸÷³ÉÔ±±äÁ¿ÔÚ´æ·ÅµÄʱºò¸ù¾ÝÔڽṹÖгöÏÖµÄ˳ÐòÒÀ´ÎÉêÇë¿Õ¼ä£¬Í¬Ê±°´ÕÕÉÏÃæµÄ¶ÔÆ뷽ʽµ÷ÕûλÖ㬿ÕȱµÄ×Ö½ÚVC»á×Ô¶¯Ìî³ä¡£
         ¢Ú ͬʱVCΪÁËÈ·±£½á¹¹µ


Ïà¹ØÎĵµ£º

¶ÑÕ»µÄC´úÂëʵÏÖ

2009-09-13     16:42:43  
 ½ñÌìʵÏÖ¶ÑÕ»½á¹¹²¿·ÖµÄ´úÂ룬²¢ÓÃÒ»¼òµ¥³ÌÐò²âÊԳɹ¦¡£
stack.h:
#ifndef _STACK_H_
#define _STACK_H_
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#define STACK_INIT_SIZE 5
#define STACKINCREMENT 5
t ......

cºê¶¨ÒåµÄ¼¼ÇÉ×ܽá


1,·ÀÖ¹Ò»¸öÍ·Îļþ±»Öظ´°üº¬
#ifndef COMDEF_H
#define COMDEF_H
//Í·ÎļþÄÚÈÝ
#endif
2,ÖØж¨ÒåһЩÀàÐÍ,·ÀÖ¹ÓÉÓÚ¸÷ÖÖƽ̨ºÍ±àÒëÆ÷µÄ²»Í¬,¶ø²úÉúµÄÀàÐÍ×Ö½ÚÊý²îÒì,·½±ãÒÆÖ²¡£
typedef unsigned char      boolean;     /* Boolean value type. */
typedef ......

Ò»µÀcµÄÃæÊÔÌ⣬´óÊýÏà³Ë

 http://www.cnblogs.com/hoodlum1980/archive/2007/08/15/857067.html
Ìâ¸É£ºÊäÈëÁ½¸ö½Ï´óµÄÊý£¬Êä³öÏà³ËµÄ½á¹û¡£
Òâ˼Ҳ¾ÍÊÇÁ½¸öÊýºÜ´ó£¬³¬³öÁËintµÄ´æ´¢·¶Î§¡£
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define N 100
void GetDigits( ......

extern "C"µ×²ãÔ­Àí

ͨ³££¬ÔÚCÓïÑÔµÄÍ·ÎļþÖо­³£¿ÉÒÔ¿´µ½ÀàËÆÏÂÃæÕâÖÖÐÎʽµÄ´úÂ룺
#ifdef __cplusplus
extern "C" {
#endif
/**** some declaration or so *****/
#ifdef __cplusplus
}
#endif /* end of __cplusplus */
ÄÇô£¬ÕâÖÖд·¨Ê²Ã´ÓÃÄØ£¿Êµ¼ÊÉÏ£¬ÕâÊÇΪÁËÈÃCPPÄܹ»ÓëC½Ó¿Ú¶ø²ÉÓõÄÒ»ÖÖÓï·¨ÐÎʽ¡£Ö®ËùÒÔ²ÉÓÃÕâÖÖ·½Ê½ ......

½«Win32 C/C++Ó¦ÓóÌÐòǨÒƵ½Linux

±¾ÎĵÄÄÚÈÝÊÇ Win32 API£¨ÌرðÊǽø³Ì¡¢Ï̺߳͹²ÏíÄÚ´æ·þÎñ£©µ½ POWER ÉÏ Linux µÄÓ³Éä¡£±¾ÎÄ¿ÉÒÔ°ïÖúÄúÈ·¶¨ÄÄÖÖÓ³Éä·þÎñ×îÊʺÏÄúµÄÐèÒª¡£×÷ÕßÏòÄúÏêϸ½éÉÜÁËËûÔÚÒÆÖ² Win32 C/C++ Ó¦ÓóÌÐòʱÓöµ½µÄ API Ó³Éä¡£
¸ÅÊö
Óкܶ෽ʽ¿ÉÒÔ½« Win32 C/C++ Ó¦ÓóÌÐòÒÆÖ²ºÍǨÒƵ½ pSeries ƽ̨¡£Äú¿ÉÒÔʹÓÃÃâ·ÑÈí¼þ»òÕßµÚÈý·½¹¤¾ßÀ´ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ