1-5 C語言的編譯、連結和執行

  • warning: Declaration of views_handler_argument::init(&$view, &$options) should be compatible with views_handler::init(&$view, $options) in /home/xnvgu7/public_html/sites/all/modules/views/handlers/views_handler_argument.inc on line 745.
  • warning: Declaration of views_handler_filter::options_validate(&$form, &$form_state) should be compatible with views_handler::options_validate($form, &$form_state) in /home/xnvgu7/public_html/sites/all/modules/views/handlers/views_handler_filter.inc on line 585.
  • warning: Declaration of views_handler_filter::options_submit(&$form, &$form_state) should be compatible with views_handler::options_submit($form, &$form_state) in /home/xnvgu7/public_html/sites/all/modules/views/handlers/views_handler_filter.inc on line 585.
  • warning: Declaration of views_handler_filter_boolean_operator::value_validate(&$form, &$form_state) should be compatible with views_handler_filter::value_validate($form, &$form_state) in /home/xnvgu7/public_html/sites/all/modules/views/handlers/views_handler_filter_boolean_operator.inc on line 149.
  • warning: Declaration of views_plugin_style_default::options(&$options) should be compatible with views_object::options() in /home/xnvgu7/public_html/sites/all/modules/views/plugins/views_plugin_style_default.inc on line 25.
  • warning: Declaration of views_plugin_row::options_validate($form, &$form_state) should be compatible with views_plugin::options_validate(&$form, &$form_state) in /home/xnvgu7/public_html/sites/all/modules/views/plugins/views_plugin_row.inc on line 135.
  • warning: Declaration of views_plugin_row::options_submit($form, &$form_state) should be compatible with views_plugin::options_submit(&$form, &$form_state) in /home/xnvgu7/public_html/sites/all/modules/views/plugins/views_plugin_row.inc on line 135.

完成了一個C語言的程式後,必需經過編譯、連結,才能執行。

開發環境IDE:編譯、連結及執行均需在一個「環境」中進行,本書範例所使用的IDE是Dev-C++

編譯:由編譯器Compiler將C程式(一般是以.c為結尾的檔案)編譯成目的碼程式(一般是以.o為結尾的檔案)。(有些情況是用解譯器interpreter)

連結:將所有的目的碼.o程式和程式庫函式Library(也是以.o為結尾的檔案,由Dev-C++提供)經由連結器Linker合成為「執行檔」executable/excution file。

執行:執行「執行檔」executable/excution file。

 

編譯器Compiler如何將C程式?以 a= b+1; 為例:

編譯器Compiler先找出「a」、「=」、「b」、「+」、「1」這些Token,這叫做Lexical analysis。

接著查驗各個Token和其前後Token是否合於語法Syntax,若不合,會出現Syntax error。這個步驟稱為Syntatic analysis。

接著查驗整句是否有意義Semantic,若否,會出現Semantic error,這個步驟稱為Semantic analysis。

Syntax error、Semantic error範例: 下載原始碼