ソースファイルの作成
次は、scanner_test プロジェクトのソースファイルを作成します。
- [C/C++ Projects (C/C++ プロジェクト)] ビューから scanner_test プロジェクトを選択し、右クリックでコンテキスト・メニューを開きます。
- コンテキスト・メニューで [New (新規)] > [Source File (ソースファイル)] を選択します。ファイル名に scanner_test.c と入力し、親フォルダーはプロジェクト・フォルダー (scanner_test) のままにしておきます。
- [Finish (終了)] をクリックします。
エディタービューに scanner_test.c が表示されます。次のプログラムを入力します。
#include <stdio.h>
#include "scanner_test.h"
int main(void){
printf("Hello from scanner_test.\n");
scanner_test_func();
return(0);
}
void scanner_test_func(){
printf("Hello from scanner_test_func.\n");
return;
}
編集を終えたらファイルを必ず保存してください。
次に、プロジェクト・フォルダー内に、プロジェクトのインクルード・ファイルのためのフォルダーを作成します。
- [C/C++ Projects (C/C++ プロジェクト)] ビューから scanner_test プロジェクトを選択し、右クリックでコンテキスト・メニューを開きます。
- コンテキスト・メニューで [New (新規)] > [Folder (フォルダー)] を選択します。[Folder name (フォルダー名)] に scanner_test_includes と入力します。親フォルダーはプロジェクト・フォルダー (scanner_test) です。[Finish (終了)] をクリックします。
- [C/C++ Projects (C/C++ プロジェクト)] ビューから新しく作成した scanner_test_includes フォルダーを選択し、コンテキスト・メニューの [New (新規)] > [Header File (ヘッダーファイル)] で scanner_test.h という名前のヘッダーファイルを作成します。新しく作成したフォルダー (scanner_test/scanner_test_includes) が親フォルダーになります。
- 最後に、エディターを使用して、scanner_test.h に次のコードを入力します。
#ifndef SCANNER_TEST_H
#define SCANNER_TEST_H 1
void scanner_test_func();
#endif