硬汉嵌入式论坛

 找回密码
 立即注册
查看: 974|回复: 4
收起左侧

[MDK] exit未定义是什么问题

[复制链接]

8

主题

36

回帖

60

积分

初级会员

积分
60
发表于 2022-7-23 17:59:31 | 显示全部楼层 |阅读模式
我在使用MDK的Use MicroLIB选项时,函数中调用exit(1),编译时提示exit未定义是什么问题,程序中已添加<stdlib.h>头文件,有没有人知道的。

回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
106938
QQ
发表于 2022-7-24 00:49:43 | 显示全部楼层
微库没有这个。
回复

使用道具 举报

8

主题

36

回帖

60

积分

初级会员

积分
60
 楼主| 发表于 2022-7-25 09:03:23 | 显示全部楼层
stdlib.h文件里是这样写的
extern _ARMABI_NORETURN void exit(int /*status*/);
   /*
    * causes normal program termination to occur. If more than one call to the
    * exit function is executed by a program, the behaviour is undefined.
    * First, all functions registered by the atexit function are called, in the
    * reverse order of their registration.
    * Next, all open output streams are flushed, all open streams are closed,
    * and all files created by the tmpfile function are removed.
    * Finally, control is returned to the host environment. If the value of
    * status is zero or EXIT_SUCCESS, an implementation-defined form of the
    * status 'successful termination' is returned. If the value of status is
    * EXIT_FAILURE, an implementation-defined form of the status
    * 'unsuccessful termination' is returned. Otherwise the status returned
    * is implementation-defined.
    */

头文件里有对exit函数申明了。
回复

使用道具 举报

8

主题

36

回帖

60

积分

初级会员

积分
60
 楼主| 发表于 2022-7-28 11:17:19 | 显示全部楼层
已解决 自己定义下这个函数 如:
_ARMABI_NORETURN void exit(int status)
{
while(1);
}
注意:这是一个无返回的函数。
回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
106938
QQ
发表于 2022-7-28 11:26:41 | 显示全部楼层
365497604 发表于 2022-7-28 11:17
已解决 自己定义下这个函数 如:
_ARMABI_NORETURN void exit(int status)
{

这个属于重定向,防止警告,也行。

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|Archiver|手机版|硬汉嵌入式论坛

GMT+8, 2024-5-11 03:56 , Processed in 0.191609 second(s), 25 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表