eclipseにデバッガをインストール

  • >はまった。できない。

1)brewのインストール
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

2)gdbのインストール
brew install gdb

証明書を作成する

Keychain Accessを開きます。 (Applications/Utilitiesディレクト
名前(例:gdbcert)。
証明書タイプは"Self Signed Root"を選択してください。そして"Let me override defaults"チェックボックスにチェック

gdbのsigning

codesign -fs gdbcert /usr/local/bin/gdb
これでgdbはインストールされた.

3)eclipse側の設定
EclipseのPreferencesを開きます(プロジェクトのPreferencesではありませんので注意)。サイドバーのツリーからC/C++→Debug→GDBを開き、GDB debugger欄に、/usr/local/bin/gdbと記入します。
OS XでGDBを使う(ためにコード署名をする) - Qiita


以上

vectorクラス、動的配列

動的に配列サイズが拡張される

#include <vector>
#include <iostream>
void printAll(const std::vector<int>&);
int main() {
using std::vector;
vector<int> ary(10);

ary[0] = 1; // 配列のような使用が可能
ary.at(1) = 2; // ary[1] = 2とほぼ等価
printAll(ary);

ary.resize(2); // 要素数を2に減らす
printAll(ary);

ary.reserve(20); // 許容量を20に増やす
printAll(ary);

ary.resize(5, 3); // 要素数を5に増やし、3で初期化
printAll(ary);
}
 

macでeclipseにcmakeと連動させること [eclipse]

1)cmakeをインストール,https://cmake.org/
コマンドラインで使えるように設定する.GUIのcmakeを開いて設定.
f:id:kuwabot:20170414233014p:plain

2)eclipse側でprojectでbuildディレクトリを指定.
f:id:kuwabot:20170414233016p:plainf:id:kuwabot:20170414233018p:plain

3)makefileを作りたいフォルダでcmake

01.helloworld kuwakichi$ cmake .

ゴミと一緒にmakefileができてる.
f:id:kuwabot:20170414233020p:plain


f:id:kuwabot:20170522183709p:plain
use default command
上のチェックボックスは外すこと.

4)CMakeList.txtの例

cmake_minimum_required(VERSION 2.8)

PROJECT(HelloWorld)

include_directories ("${PROJECT_SOURCE_DIR}/${sub}")

add_definitions("-Wall -std=c++11")