xcode - Xcode 警告我“malloc”的隐式声明,但 stdlib.h 包含在标头中
问题描述
我正在尝试在 Xcode 中的 C 中创建堆栈数据类型,因此使用堆栈初始化函数。
以下是在 DeckStack.c 中找到的
#define DS DeckStack
#include "DeckStack.h"
struct _DeckStack {
void *top;
void *cards[40];
};
DeckStack* stack_init(void) {
DS *new_deckStack = NULL;
new_deckStack = (DS*) malloc(sizeof(DS));
return new_deckStack;
}
但是 Xcode 抱怨 malloc 的隐式声明,但 stdlib.h 包含在 DeckStack.h 中:
#ifndef DeckStack_h
#define DeckStack_h
#include <stdio.h>
#include <stdlib.h>
typedef struct _DeckStack DeckStack;
/* @brief
* Creates a new deck
*/
DeckStack* stack_init(void);
#endif /* DeckStack_h */
解决方案
已解决,只需按几次 Enter,.c 文件就会使用标题的内容进行自我更新。
推荐阅读
- angular - 包含自定义组件 html 的角度管道
- linux - 从文本文件中查找内容与某行匹配的文件
- javascript - 用钩子反应功能组件 - 从用 reducer 编写的函数中获取响应
- sql - 是否有一个 SQL 函数可以在 Date 列中填充缺失的日期并用以前的值填充 B 列中的相同记录?(PostgresSQL)
- html - 如何以角度更改列表框中第一个元素的颜色?
- c# - 为什么在 xaml 中绑定 ItemsSource 时 ui 更新但在代码中分配它时不更新?
- facebook - facebook 服务器发送实时视频评论事件,仅提供视频所有者评论
- java - ConstraintValidation 不适用于 Rest Api 请求
- javascript - 在回发时我不想改变表单的视觉效果?
- ios - 为 Pushkit 分配 PKPushRegistryDelegate 时如何消除类型错误?