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

C runtime lib Ḭ̈߳²È«

ÖÜÎ忪»á×öÍŶӳÉÔ±codereivew£¬ ÓÐͬÊÂÌá³öÁËÒ»¸ö¹ØÓÚgmtime¶àÏß³ÌÊÇ·ñ°²È«µÄÎÊÌ⣬ µ±Ê±¾õµÃ³ÌÐòLinkÁËVCµÄ¶àÏ߳̿⣬Ӧ¸Ã²»ÊÇÎÊÌâ¡£»¹ºÃ»ØÍ·ºËʵÁËһϣ¬·¢ÏÖÁ˾¹ÊÇÒ»¸öDZÔÚµÄbug¡£
³ÌÐò·ÖÔÚapplication£¨Íê³ÉÏîÄ¿ÌØ¶¨¹¦ÄÜ£©ºÍframework£¨¿ÉÖØÓõĺËÐŦÄÜ£©Á½²¿·Ö£¬Ïß³ÌµÄÆô¶¯ÓÉframeworkÍê³É¡£ appÖÐʹÓÃÁËgmtime/localtimeµÈC¿âº¯Êý¡£
gmtime/localtimeµÈCº¯ÊýÊÇ·ÇḬ̈߳²È«µÄ£¬Õâ¸önÄêǰ¾ÍÖªµÀ£¬ Ò²ÖªµÀÔÚWindowsƽ̨ÉÏVCÓÐMT°æ±¾µÄruntime library£¬Í¨¹ýÏ̵߳ľֲ¿´æ´¢£¨TLS£©ÊµÏÖÁË/mt Á´½ÓʱµÄḬ̈߳²È«¡£ È»¶øÏß³ÌµÄÆô¶¯±ØÐëͨ¹ýCÔËÐÐʱ¿âµÄ_beginthreadex, ¶ø²»ÊÇwin32 API CreateThead ¡£²»ÐҵĵÄÊǵ±ÄêframeworkµÄʵÏÖÕßÃ²ËÆ²»Çå³þ_beginthreadexÓëCreateThreadµÄÇø±ð£¨BTW£¬ Õâ¸öÊǵ±Äê½øÈëµÚÒ»¼Ò¹«Ë¾µÄÒ»µÀÃæÊÔÌ⣬ËùÒÔÓ¡ÏóÆÄΪÉî¿Ì£©£¬Ö±½Óµ÷CreateThreadÆô¶¯ÁËÏ̡߳£
½â¾ö·½°¸µ÷²éÖУ¬VC CRT¾¹ÊÇûÓÐgmtime_r/localtime_r¡£
²Î¿¼×ÊÁÏ£º
http://social.msdn.microsoft.com/forums/en-US/vclanguage/thread/c727ae29-5a7a-42b6-ad0b-f6b21c1180b2
http://www.tech-archive.net/Archive/VC/microsoft.public.vc.language/2006-02/msg00013.html


Ïà¹ØÎĵµ£º

Optimizing Your C/C++ Applications


C/C++ optimizing compilers are great--but there *are* a few techniques for hand-tuning your code to run as efficiently as possible on the AMD Athlon64 and Opteron processors, especially when developing DLLs, device drivers, or other performance-bound pieces of code.
Alan Zeichick  
Share | ......

[VC]º¯Êýµ÷ÓÃÔ¼¶¨½âÎö(C/C++)

C/C++º¯Êýµ÷ÓÃÔ¼¶¨ºÍº¯ÊýÃû³ÆÐÞÊιæÔò̽ÌÖ
×÷ÕߣºÐǹ죨oRbIt£©
 
ʹÓÃC/C++ÓïÑÔ¿ª·¢Èí¼þµÄ³ÌÐòÔ±¾­³£Åöµ½ÕâÑùµÄÎÊÌ⣺ÓÐʱºòÊdzÌÐò±àÒëûÓÐÎÊÌ⣬µ«ÊÇÁ´½ÓµÄʱºò×ÜÊDZ¨¸æº¯Êý²»´æÔÚ£¨¾­µäµÄLNK
2001´íÎ󣩣¬ÓÐʱºòÊdzÌÐò±àÒëºÍÁ´½Ó¶¼Ã»ÓдíÎ󣬵«ÊÇÖ»Òªµ÷ÓÿâÖеĺ¯Êý¾Í»á³öÏÖ¶ÑÕ»Òì³£¡£ÕâЩÏÖÏóͨ³£ÊdzöÏÖÔÚCºÍC ......

C/C++ ÓëÔËËãºÍ»òÔËËãת»»´óСд

// & Óë,½«Ö¸¶¨Î»ÖÃÉèÖÃΪ0     | »ò,½«Ö¸¶¨Î»ÖÃÉèÖÃΪ1
//×¢: Ö»Õë¶Ô´¿×ÖĸµÄÇé¿ö
#include <stdio.h>
#include <string>
int main()
{
char str[6] = "xxing";
std::string str1 = "INGXX";
for(int i = 0; i < 5; i++)
{
str[i] &= 0xdf; ......

memcachde Óë c/c++ Ó¦ÓÃ

ÐÞ¸Ämakefile£¬ÔÚLIBSÀïÃæ¼ÓÉÏ-lmemcached£¬±ÈÈçÔ­À´ gcc test.c£¬ÏÖÔÚ gcc test.c -lmemcached¡£Õâ¸ö¿â¾ÍÊÇlibmemcachedÌṩµÄ¡£
È»ºóÌí¼Ó#include<libmemcached/memcached.h>£¬Õâ¸öÎļþÒ²ÊÇlibmemcachedÌṩµÄ¡£
Ö÷º¯ÊýÀïÃæÐèÒªÌí¼Ó£º
    memcached_st *memc;
    uint32_t&nbs ......

C/C++Êý¾ÝÀàÐÍ(ÍøÉÏ×ÊÁÏ×ܽá)

1. cÓïÑÔÖеÄÕûÊýÀàÐÍÓÐchar, short, int, longµÈ¼¸ÖÖ, ÏÂÃæÊÇCÓïÑÔ¶ÔÿÖÖÊý¾ÝÀàÐͳ¤¶ÈµÄ¹æ¶¨:
(a). shortºÍlongÀàÐ͵ij¤¶È²»Ïàͬ
(b). intÀàÐÍͨ³£Í¬¾ßÌå»úÆ÷µÄÎïÀí×Ö³¤Ïàͬ
(c). shortͨ³£ÊÇ16bits, intͨ³£ÊÇ16bits or 32bitsÿÖÖ±àÒëÆ÷¿ÉÒÔ¸ù¾ÝÓ²¼þµÄ²»Í¬×ÔÓÉÈ·¶¨, µ«ÊÇshortºÍint±ØÐë×îÉÙÊÇ16bits, ¶ølongÀàÐͱØÐë× ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ