1
私のosバージョンはsierra 10.12.1であり、コードバージョンは1.8.1です。 vsコードにC++プラグインをインストールしました。そして、私はC++プロジェクトを作成しました。 私のC++ソースファイルがありました。vsコードC++のブレークポイントはMacでは動作しません
my_simple.cc
int main(int argc, char const *argv[])
{
printf("%s\n", "******begin******");
int a = 1;
int b = a;
printf("%s\n", "******end******");
return 0;
}
launch.json
{
"version": "0.2.0",
"configurations": [
{
"preLaunchTask": "pre_compile",
"showDisplayString": true,
"name": "my_debug",
"type": "cppdbg",
"request": "launch",
"program": "${file}.o",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"environment": [],
"externalConsole": false,
"osx": {
"MIMode": "lldb"
}
}
]
}
tasks.json
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "g++",
"isShellCommand": true,
"args": [
],
"showOutput": "always",
"echoCommand": true,
"suppressTaskName": true,
"tasks": [
{
"taskName": "pre_compile",
"args": [
"${file}",
"-o${file}.o"
],
"isBuildCommand": true
}
]
}
私はmy_simple.ccしてからコンパイルするF5キーを押して、いくつかのブレークポイントを追加するとし、それを実行します。ブレークポイントは期待どおりに機能しませんでした。私のコードで間違いを見つけるのを助けてください。おかげ
どこでブレークポイントを設定しますか?コンパイラは存在しない変数を最適化しているかもしれません。 –
コンパイラは関数を次のように最適化できます: 'int main(int argc、char const * argv []) { fputs(" ****** begin ****** \ n ** **** end ****** \ n "、stdout); return 0 } ' - しかし、そのレベルの侵略は珍しいです。 –
'printf( "%i \ n"、b);'を追加して、ブレークポイントを設定しようとしました。しかし、ブレークポイントはまだ機能しません。 – user4468848