前提
C言語をVScodeを利用して勉強しています。
利用OSはWindows 11 64bitです。
以下に記す該当のソースコードを実行すると[出力]は正常ですが、[問題]の項目にエラーメッセージが表示されました。
実現したいこと
- 問題の項目のエラーが表示されないようにしたい
発生している問題・エラーメッセージ
'hello' accessing 1024 bytes in a region of size 7 [-Wstringop-overflow=]
該当のソースコード
C言語
1#include <stdio.h> 2 3typedef char String[1024]; 4 5void hello(String name) { 6 printf("%sさん、こんにちは\n", name); 7} 8 9int main(void) { 10 hello("田中"); 11 return 0; 12}
試したこと
”田中”の文字を"t"に変更した場合、エラーメッセージの7が2に変わりました。
typedef char String[1024]をtypdef char String[64]に変更するとエラーメッセージの1024が64に変わりました。
補足情報(FW/ツールのバージョンなど)
c_cpp_properties.json
1{ 2 "configurations": [ 3 { 4 "name": "MinGW", 5 "includePath": [ 6 "${workspaceFolder}/**", 7 "C:\\gcc\\mingw64\\include" 8 ], 9 "defines": [ 10 "_DEBUG", 11 "UNICODE", 12 "_UNICODE" 13 ], 14 "windowsSdkVersion": "10.0.22000.0", 15 "compilerPath": "C:/gcc/mingw64/bin/gcc.exe", 16 "cStandard": "c17", 17 "cppStandard": "c++17", 18 "intelliSenseMode": "windows-gcc-x64" 19 } 20 ], 21 "version": 4 22}
launch.json
1{ 2 "configurations": [ 3 { 4 "name": "C/C++: gcc.exe アクティブ ファイルのビルドとデバッグ", 5 "type": "cppdbg", 6 "request": "launch", 7 "program": "${fileDirname}\\${fileBasenameNoExtension}.exe", 8 "args": [], 9 "stopAtEntry": false, 10 "cwd": "${fileDirname}", 11 "environment": [], 12 "externalConsole": false, 13 "MIMode": "gdb", 14 "miDebuggerPath": "C:\\gcc\\mingw64\\bin\\gdb.exe", 15 "setupCommands": [ 16 { 17 "description": "gdb の再フォーマットを有効にする", 18 "text": "-enable-pretty-printing", 19 "ignoreFailures": true 20 }, 21 { 22 "description": "逆アセンブリ フレーバーを Intel に設定", 23 "text": "-gdb-set disassembly-flavor intel", 24 "ignoreFailures": true 25 } 26 ], 27 "preLaunchTask": "C/C++: gcc.exe アクティブなファイルのビルド" 28 }, 29 ], 30 "version": "2.0.0" 31}
tasks.json
1{ 2 "tasks": [ 3 { 4 "type": "cppbuild", 5 "label": "C/C++: gcc.exe アクティブなファイルのビルド", 6 "command": "C:\\gcc\\mingw64\\bin\\gcc.exe", 7 "args": [ 8 "-fdiagnostics-color=always", 9 "-g", 10 "${file}", 11 "-o", 12 "${fileDirname}\\${fileBasenameNoExtension}.exe" 13 ], 14 "options": { 15 "cwd": "${fileDirname}" 16 }, 17 "problemMatcher": [ 18 "$gcc" 19 ], 20 "group": { 21 "kind": "build", 22 "isDefault": true 23 }, 24 "detail": "デバッガーによって生成されたタスク。" 25 } 26 ], 27 "version": "2.0.0" 28}

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2022/09/05 14:26
2022/09/05 14:48
2022/09/05 15:02
2022/09/05 23:37
2022/09/06 09:53
2022/09/13 03:39