跳到主要內容

發表文章

[Coding] Compiler

Something about compiling. #compiler #link #gcc Reference PTT LinuxDev, 作者: cole945 (躂躂..) 看板: LinuxDev, 標題: [心得] 用gcc 自製Library, 時間: Sun Nov 5 04:15:45 2006 Static Link Compile 時將 library 加入程式碼,執行快但佔空間,code size 和 mem 使用都比較多 Compile source codes to generate object files $ gcc -c file1.c file2.c file3.c -c 編出 object 檔 Create a static library named libmylib.a $ ar rcs lib mylib .a file1.o file2.o file3.o 把一堆 object 檔用 ar(archiver) 包裝集合起來,檔名以`.a’ 結尾 Using a Static Library to generate a executable files $ gcc -o main main.c -L. -l mylib -L: the directory of the library. 可以指定多次 -LDIR -l: the name of the library (注意 藍色 部分是 match 的) Dynamic Link Compile 時不將 library 加入程式碼,執行程式的時後再將 library 載入程式碼,若有多個程式共用同一個 library,只需載一個 library 進 memory Compile source code $ gcc -c -fPIC file1.c file2.c file3.c -fPIC 表示要編成 position-independent code,這樣不同 process 載入 shared library 時,library 的程式和資料才能放到記憶體不同位置。-fPIC 較通用於不同平台,但產生的 code 較大,而且編譯速度較慢 Create a shared library...

[Coding] Python

comment:   single line: #   multiple line: ''' ... ''' encode: # -*- coding: utf-8 -*- math operation: 先乘除後加減 5**2: 5 的平方 5**0.5: 平方根 log(8, 2) => 3 Data type None 就是 C 的 null 變數型態不需宣告 only int, float, string string 'mystring' mychar = string[0] #mychar is still string type string[2:5] s[2] == 'a' s += "append string" array/linked-list/stack (implemented by array)  fruits = ['orange', 'apple', 'pear', 'banana', 'kiwi', 'apple', 'banana'] len(fruits) fruits.count('apple') => 2 fruits.index('banana') => 3 fruits.index('banana', 4) => 6 fruits.remove('banana') del fruits[-1] fruits.insert(3, 'grape') fruits.reverse() fruits.append('grape') fruits += ['orange', 'peach'] fruits.sort() fruits.pop() => 'banana' nD 2D array 取值是用 a[i][j],不是用 a[i, j],後者回傳的是 tupl...

Let's Move On

今天決定要建個部落格 身為資工系的學生, 又那麼愛做筆記 XD 卻到今天才想做這件事似乎有點落漆 還沒明確知道想用來記錄些什麼, 有可能只是與程式相關的東西, 也有可能會很雜 但也很有可能過了一年什麼屁都沒有, 到時候也可以拿出來嘲笑自己一下自我檢討一番 Decide creating the blog today. It seems abnormal for a computer science student to do this so late. After all, I like taking note a lots... Still not sure about what am gonna write here. Maybe all about programming. Maybe it will be really mixed. Nevertheless... very likely that it will still be empty after a year... Then I can open it and piss myself. 迅速 Google 了一下該用哪個平台, 只想找個簡單好用的 外貌先決下 wordpress 和 blogger 脫穎而出, 進一步看了一下覺得並沒有複雜架站的需求所以最後選了 blogger