From cc9a29dec1578e015ac391def032afe247d86909 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=AF=E4=B8=AD=E7=A7=80?= Date: Wed, 9 Aug 2023 02:15:32 +0000 Subject: [PATCH] =?UTF-8?q?fix=20process=5Ftree=E7=BC=96=E8=AF=91=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=20=E8=A7=A3=E5=86=B3=E6=8A=A5=E9=94=99=EF=BC=9A=20pro?= =?UTF-8?q?cess=5Ftree.c:126:5:=20error:=20=E2=80=98for=E2=80=99=20loop=20?= =?UTF-8?q?initial=20declarations=20are=20only=20allowed=20in=20C99=20mode?= =?UTF-8?q?=20=20=20=20=20=20for=20(int=20i=20=3D=200;=20i=20<=20maxLen=20?= =?UTF-8?q?-=201;=20i++)=20=20=20=20=20=20^=20process=5Ftree.c:126:5:=20no?= =?UTF-8?q?te:=20use=20option=20-std=3Dc99=20or=20-std=3Dgnu99=20to=20comp?= =?UTF-8?q?ile=20your=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 原因:gcc基于c89标准,换成C99标准就可以在for循环内定义i变量了;该语法在gcc中是错误的,必须先先定义i变量 Signed-off-by: 冯中秀 --- source/tools/detect/generic/process_tree/process_tree.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/tools/detect/generic/process_tree/process_tree.c b/source/tools/detect/generic/process_tree/process_tree.c index 5b44f5b8..404ad98d 100644 --- a/source/tools/detect/generic/process_tree/process_tree.c +++ b/source/tools/detect/generic/process_tree/process_tree.c @@ -123,7 +123,8 @@ static int libbpf_print_fn(enum libbpf_print_level level, */ static void extract_process_args(char *dst, char *src, int maxLen) { - for (int i = 0; i < maxLen - 1; i++) + int i; + for (i = 0; i < maxLen - 1; i++) { if (src[i] == '\0') { -- Gitee