当数组作参数时
C语言中的数组和指针总保持着’千丝万缕’的联系,这里仅针对数组作为函数实参时的情况做些说明^_^。 C语言中的数组可分为一维数组和多维数组两类,而多维数组中又以二维数组最为常见。这里也仅针对这一维数组和二维数组作简要说明。 ...
C语言中的数组和指针总保持着’千丝万缕’的联系,这里仅针对数组作为函数实参时的情况做些说明^_^。 C语言中的数组可分为一维数组和多维数组两类,而多维数组中又以二维数组最为常见。这里也仅针对这一维数组和二维数组作简要说明。 ...
闲暇时翻阅’C专家编程’,再次看到对C语言变量声明的理解一节,遂想起我曾经写过的那篇利用’right-left’规则分析复杂的C语言变量声明的文章’C复杂声明解析’,发现其中的例子的对比性不够强,所以决定再用一篇短文来再阐述。 ...
第一次看《C专家编程》一书时关于其采用的’优先级规则’分析C复杂声明时看得很糊涂,在理解’right-left’规则分析C复杂声明后,再回过头来看’优先级规则’,居然发现它们的异曲同工之妙^_^。 其实’优先级规则’的分析过程极其类似’right-left’规则,下面首先摘录’优先级规则’的’口诀’,然后再’一招一式’的细致讲解^_^。 ...
我有这样的一个习惯,就是看书的时候总是喜欢自问自答,这不周末第二次温习’C专家编程’一书,便有了如下若干问题,明为提问,实则是在提醒自己好好想想这些问题,如果大家有兴趣,也可以给出你自己的答案,如果觉得琢磨不透,可翻看’C专家编程’一书,或多敲几次键盘,自己试上一把! ...
程序员是追求完美的一族,即使是一般的程序员大多也都不想看到自己的程序中有甚至那么一点点的瑕疵。遇到任意一条编译器警告都坚决不放过。有人会说:我们可以使用比编译器更加严格的静态代码检查工具,如splint。这个建议也很不错。不过lint工具使用起来较繁琐,有时候还需要记住一些特定符号并插入到你自己的代码中才行,门槛较高,这也让很多人止步于此。那么我们就从此放弃么?不,如今的编译器做得都很好,它可以帮助我们的找到绝大多数可能出现问题的代码,前提是你要学会控制编译器去找到这些问题代码,而熟悉编译器的警告选项恰恰是体现控制力的好方法。当你可以自如控制编译器警告输出的时候,你就算是’入道’了,同时你对语言的理解也更进一步了。 ...
After being decompressed, the kernel image starts with another ‘startup_32′ function included in $(linux-2.6.15.3_dir/arch/i386/kernel/head.S’. This ‘head.S’ is the second one in linux source package, which is also called ‘kernel head’. And it is exactly what we want to describe in this artical. ...
_Why do we do this? Don’t ask me.. Incomprehensible are the ways of bootloaders. _ — comments in arch/i386/boot/compressed/misc.c There are two ‘head.S’ in linux source package. One is in $(Linux-2.6.15.3\_dir/arch/i386/boot/compressed and the other one is in $(Linux-2.6.15.3_dir/arch/i386/kernel. The first one will be analyzed in this artical. Before we go ahead, let’s show a news of linux, that is ‘Army leans toward Linux for FCS(Future Combat System)’. ...
The phase we talked about before is in ‘Real-address Mode’, which runs 16-bit program modules. At the tail of “Begin ‘setup.S’”, we had moved to ‘Protected Mode’, which usu runs 32-bit program modules. So there are two big problems which are ‘How to transfer control between 16-bit code and 32-bit code’ and how to transfer control from ‘real-mode’ to protected mode’. They are also what we wanna talk about in this artical. ...
So far we have arrived at the gate leading to the real kernel. And we’d better stop for a short break in order that we would have more energy to go ahead. Now let’s examine what we do to memory these days. Virtually what we want to do is drawing some pictures to describe the layout of the memory in various phases. For the layout is related to the bootloader, we’d better make our work based on the following assumption: The machine has two systems installed (Windows XP and Linux) and uses LILO as the bootloader. Let us look at the LILO configuration: ...
It is time for ‘setup.S’ to show its power. The ‘setup.S’ is loaded by the bootloader and virtually it belongs to neither the ‘bootstrap’ routine nor the kernel program, although it is a portion of the kernel image. The source of the ‘setup.S’ is kinda ‘big’ and what it does can be summarized into one word: “the ‘setup.S’ is responsible to establish the environment for the execution of the kernel program”. ...