#1295-D: Deprecated declaration xxxx- give arg types 解决方法

Author: Bruce Liu Posted on: 2020-10-08 10:12:30 Visited: 1305

编译程序时出现“#1295-D: Deprecated declaration xxxx- give arg types”中文释义:给定函数的参数的类型过时,

解决办法: 在函数void xxxx()声明和定义的时候定义参数类型,无参函数定义为void,即可解决该问题。

示例:

void testfun()
{
  printf("this is a test function\r\n");
}

变为

void testfun(void)
{
  printf("this is a test function\r\n");
}

注意,无参函数定义为void,只需要在定义(h文件)和实现(c文件)中这样,实际函数调用时,不需要写参数。

void invoketest(int i)
{
  testfun();
  printf("this is a invoke test %d\r\n",i);
}

 

https://developer.arm.com/documentation/dui0067/d/c-and-c---compilers/command-syntax/controlling-warning-messages

这个是一个warning信息,使用arm编译器时会报这个错,这个信息可以使用编译开关-Wd忽略。

只所以报这个错,是ANSI C语言规定的,C++则不会。

-Wd
This option suppresses the warning message:

C2215W: Deprecated declaration foo() - give arg types

This warning is normally given when a declaration without argument types is encountered in ANSI C mode.

In ANSI C, declarations like this are deprecated. However, it is sometimes useful to suppress this warning when porting old code.

In C++, void foo(); means void foo(void); and no warning is generated.

 

 




Tags:
gcc 编译 Deprecated

相关主题:

留言信息:

......期待您的留言!


增加留言、提问或者评论,不用注册,匿名提交,你提交的信息经过审核后才会显示:


© 2008-2022 CunYouLu存有录博客 村友录 存游录 鲁ICP备08005943号