C++ Tricks 2.2 I386平臺的內存佈局

farseerfc.wordpress.com 導入

2.2 I386平臺的內存佈局

衆所周知,I386是32位體系結構。因此對於絕大多數I386平臺的C++編譯器而言,sizeof(int)=sizeof(long)=sizeof(void*)=4。當然C++標準對此沒有任何保證,我們


C++ Tricks

farseerfc.wordpress.com 導入

C++ Tricks

By  FarseerFc

從今天起,我再將在 LiveSpace QQZone 同時發表一系列文章,暫定名爲“C++Tricks”。

本文旨在記錄和闡述一些本人學習C++時所得的心得、技巧。總體來看,本文涉及的內容是每一個C++程序員都應


C++ Tricks 2.3 I386平臺C函數內部的棧分配

farseerfc.wordpress.com 導入

2.3 I386平臺C函數內部的棧分配

函數使用棧來保存局部變量,傳遞函數參數。進入函數時,函數在棧上爲函數中的變量統一預留棧空間,將esp減去相應字節數。當函數執行流程途徑變量聲明語句時,如


C++ Tricks 2.4 I386平臺C函數調用邊界的棧分配

farseerfc.wordpress.com 導入

2.4 I386平臺C函數調用邊界的棧分配

當調用一個函數時,主調函數將參數以聲明中相反的順序壓棧,然後將當前的代碼執行指針(eip)壓棧,然後跳轉到被調函數的入口點。在被調函數中,通過將ebp加


C++ Tricks 2.5 I386平臺的邊界對齊(Align)

farseerfc.wordpress.com 導入

2.5 I386平臺的邊界對齊(Align)

首先提問,既然I386上sizeof(int)==4、sizeof(char)==1,那麼如下結構(struct)A的sizeof是多少?

struct A{int i;char c;};

答案是sizeof(A)==8……1+5=8?

呵呵


C++ Tricks 2.6 I386平臺C函數的可變參數表(Variable Arguments)

farseerfc.wordpress.com 導入

2.6 I386平臺C函數的可變參數表(Variable Arguments)

基於前文(2.4節)分析,我們可以不通過函數簽名,直接通過指針運算,來得到函數的參數。由於參數的壓棧和彈出操作都由主調函數進行,所以被調函數


C++ Tricks 2.7 I386平臺的其它函數調用模型

farseerfc.wordpress.com 導入

2.7 I386平臺的其它函數調用模型

上文介紹的只是I386平臺上C函數調用的標準模型,被稱作__cdecl。事實上,Microsoft Visual C++編譯器還支持其它一些函數調用模型,所有調用模型名稱皆以雙下劃線開頭

A gotcha with Solaris Volume Manager metasets

Here is something that I have learned the hard way: at least on Solaris10 x86, you cannot create a metaset unless you have a local metadb. Itcan be completely empty, but you have to have one to start with, evenif you are never going to create any local meta-disks and the like.

This is a non-trivial issue because you have to put that local metadb ona disk partition and a default Solaris install doesn't create any spareones. The result


Apple Silicon|Intel

C++ Tricks 2.1 X86概述

farseerfc.wordpress.com 導入

2.1   X86概述

所謂X86體系結構,是指以Intel8086芯片爲首的芯片所沿襲的CPU結構,一些文檔中又被稱作IA32體系結構。包括的芯片有但不限於:Intel8086至80486,奔騰(Pentium)系列處理器1


On the naming of machines (part 2)

I've recently been forcefully reminded of an important thing about naming machines , namely that you should give yourmachines hostnames that are not English words that you will use inyour email and notes. That way you can actually find where you mentionyour machines when you go searching through the same, instead of gettinglost in the clutter.

(For example, we had a machine called 'mix'. I rapidly gave up searchingour work email archive for information about its history.)

This doesn't mean that