Skip to content

Instantly share code, notes, and snippets.

@g-1
Created October 3, 2011 04:56
Show Gist options
  • Save g-1/1258464 to your computer and use it in GitHub Desktop.
Save g-1/1258464 to your computer and use it in GitHub Desktop.
意外と知られていないマクロ __FILE__, __LINE__

案外知られていないマクロなので、念のため。 こんな感じにログに埋め込んでおくと、ファイル名とライン行が出力されて便利。

DLog(@"Error:%s:%d",__FILE__,__LINE__);

下記のように#defineに定義してもよいが、処理系によってはマクロの多重展開がうまくいかない場合があるので、必ずテストすること

#define LOG( _x_ ) printf("%s:%d->%s\n",__FILE__,__LINE__,_x_)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment