错误:在’*’标记之前预期’)’

我有这个包含文件(内存.h)
#ifndef MEMORY_H
#define MEMORY_H

#ifdef  __cplusplus
extern "C" {
#endif

    typedef struct mmemory {
        int* cells;
        int* current_cell;
        int cells_number;
    } memory;

    void memory_init(memory* mymemory,int size);
    void step_left(memory* mymemory,int steps);
    void step_right(memory* mymemory,int steps);
    void cell_inc(memory* mymemory,int quantity);
    void print_cell(memory* mymemory);
    void get_char(memory* mymemory);


#ifdef  __cplusplus
}
#endif

#endif  /* MEMORY_H */

而这个实现文件(memory.c)

#include <stdlib.h>
#include "memory.h"

void
memory_init (memory* mymemory,int size)
{
    mymemory->cells = (int*) malloc (sizeof (int) * size);
    mymemory->cells_number = size;
    mymemory->current_cell = (int*) ((mymemory->cells_number / 2) * sizeof (int));
}
... //other function deFinitions follow

当我尝试编译memory.c时,每个函数定义都会出现此错误

src/memory.c:5: error: expected ‘)’ before ‘*’ token

其中第5行是memory_init()的函数定义

有人可以告诉我为什么我收到此错误

解决方法

因为系统memory.h正在影响你的memory.h,导致#include成功而不声明你的类型.几个可能的修复:

>重命名您的文件 – 可能在任何情况下都是最好的,以减少潜在的混淆.>通过前缀子目录(例如,#include< myproj / memory.h>)包含您的文件.>将文件移动到与源文件相同的目录中,允许“包含在文件名中的#include优先规则”生效.>确保C预处理器包含路径选项,将项目标题路径放在系统标题路径之前.

相关文章

本程序的编译和运行环境如下(如果有运行方面的问题欢迎在评...
水了一学期的院选修,万万没想到期末考试还有比较硬核的编程...
补充一下,先前文章末尾给出的下载链接的完整代码含有部分C&...
思路如标题所说采用模N取余法,难点是这个除法过程如何实现。...
本篇博客有更新!!!更新后效果图如下: 文章末尾的完整代码...
刚开始学习模块化程序设计时,估计大家都被形参和实参搞迷糊...