Predefined Macros (GNU C/C++)這份資料所提到的 System-specific Predefined Macros 是指針對不同的系統平台 (arm、mips 等),編譯器所預先定義的特殊巨集。若想直接看看這些預先定義的巨集,可執行以下指令:
echo | gcc -dM -E - | sort使用 Microsoft 系列編譯器的人,可參考以下資料:
Predefined Macros (MSDN)
靠軟體謀生真不易... 勤作筆記,幫助記憶...
Predefined Macros (GNU C/C++)這份資料所提到的 System-specific Predefined Macros 是指針對不同的系統平台 (arm、mips 等),編譯器所預先定義的特殊巨集。若想直接看看這些預先定義的巨集,可執行以下指令:
echo | gcc -dM -E - | sort使用 Microsoft 系列編譯器的人,可參考以下資料:
Predefined Macros (MSDN)
perl -MCPAN -e "install String::CRC::Cksum"the following error message is shown and perl rejected to install it:
Use of uninitialized value in bitwise xor (^) at at /usr/local/share/perl/5.10.0/String/CRC/Cksum.pm line 73.I managed to google the solution but in vain. Finally, I realized the problem is caused by 64-bit integer on my 64-bit Ubuntu.
and then patch it (/usr/local/share/perl/5.10.0/String/CRC/Cksum.pm, "chmod" first! it's read-only):$ sudo cpan
Terminal does not support AddHistory.
cpan shell -- CPAN exploration and modules installation (v1.9205)
ReadLine support available (maybe install Bundle::CPAN or Bundle::CPANxxl?)
cpan[1]> force install String::CRC::Cksum
--- Cksum.pm 2009-05-15 00:33:20.000000000 +0800
+++ Cksum.pm 2009-05-15 00:25:36.000000000 +0800
@@ -70,7 +70,7 @@
for(my $i = 0; $i < $n; ++$i) {
my $c = unpack 'C', substr $_[0], $i, 1;
- $cksum = ($cksum << 8) ^ $crctab[($cksum >> 24) ^ $c];
+ $cksum = ($cksum << 8) ^ $crctab[(($cksum >> 24)&255) ^ $c];
++$size;
}
@@ -111,7 +111,7 @@
while($size != 0) {
my $c = $size & 0377;
$size >>= 8;
- $cksum = ($cksum << 8) ^ $crctab[($cksum >> 24) ^ $c];
+ $cksum = ($cksum << 8) ^ $crctab[(($cksum >> 24)&255) ^ $c];
}
$cksum = ~ $cksum;
A language is said to support a style of programming if it provides facilities that make it convenient (reasonably easy, safe, and efficient) to use that style. A language does not support a technique if it takes exceptional effort or skill to write such programs; it merely enables the technique to be used.在接下來的 programming styles 介紹當中,我們可以更了解這兩個概念的不同之處。
Decide which procedures you want;也就是說,先想好一件工作需要由哪些 procedures 完成;再用最好的演算法完成這些 procedures。Fortran 算是 support 這種程式設計方式的始祖,C 也 support 這種設計方法。
use the best algorithms you can find.
Decide which modules you want;也就是說,以資料為中心,將相關的資料和 procedures 結合成各自獨立的 module。Module 和 module 之間,資料是隱藏起來的,所以此種法則也叫做 data-hiding principle。Modula-2 直接 support 這種程式設計方式,但 C 只能算是 enable 這種方法。
partition the program so that data is hidden within modules.
Decide which types you want;也就是說,先想好有哪些資料型態要操作,然後為每一個資料型態設計完整的操作程序。
provide a full set of operations for each type.
Decide which classes you want;也就是說,先想好有哪些類別要操作,然後為每一個類別設計完整的操作程序;類別和類別之間的共通特性要以繼承的方式來處理。
provide a full set of operations for each class;
make commonality explicit by using inheritance.
Decide which algorithms you want;這一部份,我還要多多努力學習才行。
parameterize them so that they work for
a variety of suitable types and data structures.