C++メモ

「C++メモ」の編集履歴(バックアップ)一覧はこちら

C++メモ」(2011/12/22 (木) 12:10:12) の最新版変更点

追加された行は緑色になります。

削除された行は赤色になります。

ヘッダファイルの読み込みについて gcc がデフォルトで検索するヘッダファイルとライブラリの場所は、基本的に/usr/include (以下のコマンドで確認することが出来ます。gcc -print-search-dirs) この場所に置かれたヘッダファイルは、コンパイル時にパスを指定することなく、 #include<****.h> で読み込める。 一方、この場所に置かれていないヘッダファイルを #include<****.h> の形で読み込みたい場合には、コンパイル時に -Iオプションを用いて、 -I/ヘッダファイルが含まれるディレクトリまでのフルパス と指定する必要がある。たとえば、openGLのヘッダファイルは /usr/local/NVIDIA_GPU_Computing_SDK/C/common/inc に置かれているので、openGLでヘッダファイル #include <GL/glut.h> を指定したければ、コンパイル時に -I/usr/local/NVIDIA_GPU_Computing_SDK/C/common/inc を付ける必要がある。 Intel compiler を使う場合の注意点 環境変数 LC_ALL => C としておかないとコンパイル時にえらーが出る。 > setenv LC_ALL C コンパイラオプション http://x68000.q-e-d.net/~68user/unix/pickup?gcc Linux上でのプログラム開発 http://www.tuat.ac.jp/~asiaprog/courses/oss/lesson01/ Windows上でのC++入門 http://keicode.com/winprimer/ 構造体の配列を引数として関数に渡す方法 http://hitorilife.com/struct.php void型変数の受け渡し Assume that you want to pass two arrays, one of doubles and one of integers. A quick but not very elegant solution is to use global variables. The simplest way to avoid using globals is to declare a structure as struct mydata{ double dar[XXX]; int iar[YYY]; }; where XXX and YYY denote the appropriate array sizes. Then, define a structure variable with struct mydata data; and fill it: data.dar[0]=7.0; data.iar[0]=-17; // etc Following this, call the appropriate LM routine passing it the address of data as the adata argument, e.g. ret=dlevmar_der(func, fjac, ..., (void *)&data); Your func and fjac routines should interpret the supplied data using type casting: struct mydata *dptr; dptr=(struct mydata *)adata; // adata is passed as void * オブジェクトの参照渡し http://wisdom.sakura.ne.jp/programming/cpp/cpp12.html フレンドクラス http://www.geocities.jp/ky_webid/cpp/language/022.html コピーコンストラクタ http://www.geocities.jp/ky_webid/cpp/language/016.html 内部クラス http://www.geocities.jp/ky_webid/cpp/language/030.html オブジェクト配列 http://ppwww.phys.sci.kobe-u.ac.jp/~akusumoto/program/detail.php?d=c/05-pointer/pointer_array Link http://www.sat.t.u-tokyo.ac.jp/~tetsuya/homeNew/research/Tips/cpp_for_researcher_1.htm N-body sample program http://www.cs.cmu.edu/~ph/859E/src/nbody/nbody.html
ヘッダファイルの読み込みについて gcc がデフォルトで検索するヘッダファイルとライブラリの場所は、基本的に/usr/include (以下のコマンドで確認することが出来ます。gcc -print-search-dirs) この場所に置かれたヘッダファイルは、コンパイル時にパスを指定することなく、 #include<****.h> で読み込める。 一方、この場所に置かれていないヘッダファイルを #include<****.h> の形で読み込みたい場合には、コンパイル時に -Iオプションを用いて、 --I/ヘッダファイルが含まれるディレクトリまでのフルパス と指定する必要がある。たとえば、openGLのヘッダファイルは /usr/local/NVIDIA_GPU_Computing_SDK/C/common/inc に置かれているので、openGLでヘッダファイル #include <GL/glut.h> を指定したければ、コンパイル時に --I/usr/local/NVIDIA_GPU_Computing_SDK/C/common/inc を付ける必要がある。 Intel compiler を使う場合の注意点 環境変数 LC_ALL => C としておかないとコンパイル時にえらーが出る。 > setenv LC_ALL C コンパイラオプション http://x68000.q-e-d.net/~68user/unix/pickup?gcc Linux上でのプログラム開発 http://www.tuat.ac.jp/~asiaprog/courses/oss/lesson01/ Windows上でのC++入門 http://keicode.com/winprimer/ 構造体の配列を引数として関数に渡す方法 http://hitorilife.com/struct.php void型変数の受け渡し Assume that you want to pass two arrays, one of doubles and one of integers. A quick but not very elegant solution is to use global variables. The simplest way to avoid using globals is to declare a structure as struct mydata{ double dar[XXX]; int iar[YYY]; }; where XXX and YYY denote the appropriate array sizes. Then, define a structure variable with struct mydata data; and fill it: data.dar[0]=7.0; data.iar[0]=-17; // etc Following this, call the appropriate LM routine passing it the address of data as the adata argument, e.g. ret=dlevmar_der(func, fjac, ..., (void *)&data); Your func and fjac routines should interpret the supplied data using type casting: struct mydata *dptr; dptr=(struct mydata *)adata; // adata is passed as void * オブジェクトの参照渡し http://wisdom.sakura.ne.jp/programming/cpp/cpp12.html フレンドクラス http://www.geocities.jp/ky_webid/cpp/language/022.html コピーコンストラクタ http://www.geocities.jp/ky_webid/cpp/language/016.html 内部クラス http://www.geocities.jp/ky_webid/cpp/language/030.html オブジェクト配列 http://ppwww.phys.sci.kobe-u.ac.jp/~akusumoto/program/detail.php?d=c/05-pointer/pointer_array Link http://www.sat.t.u-tokyo.ac.jp/~tetsuya/homeNew/research/Tips/cpp_for_researcher_1.htm N-body sample program http://www.cs.cmu.edu/~ph/859E/src/nbody/nbody.html

表示オプション

横に並べて表示:
変化行の前後のみ表示: