C++メモ

ヘッダファイルの読み込みについて

gcc がデフォルトで検索するヘッダファイルとライブラリの場所は、基本的に/usr/include

(以下のコマンドで確認することが出来ます。gcc -print-search-dirs)

この場所に置かれたヘッダファイルは、コンパイル時にパスを指定することなく、
<****.h>
で読み込める。
一方、この場所に置かれていないヘッダファイルを
<****.h>
の形で読み込みたい場合には、コンパイル時に -Iオプションを用いて、

    • I/ヘッダファイルが含まれるディレクトリまでのフルパス

と指定する必要がある。たとえば、openGLのヘッダファイルは
/usr/local/NVIDIA_GPU_Computing_SDK/C/common/inc
に置かれているので、openGLでヘッダファイル
<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/

構造体の配列を引数として関数に渡す方法



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;

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

フレンドクラス






タグ:

+ タグ編集
  • タグ:

このサイトはreCAPTCHAによって保護されており、Googleの プライバシーポリシー利用規約 が適用されます。

最終更新:2011年12月22日 12:10