C - 错误冲突类型。定义了函数原型(prototype)

标签 c function

我正处于创建 C 编译器的开始阶段。我只想做一些简单的错误处理。

有人可以解释一下为什么我仍然得到:

“‘中止’类型冲突”

即使我已经定义了 abort() 的函数原型(prototype)并且签名匹配?

#include <stdio.h>
#include <string.h>

#include "Concat.c"

/* Constant declarations */
const char TAB = '\t';

/* Variable Declarations */
char look;  /* Lookahead character */


/* Declaring function prototypes */
void getChar();
void error(char*);
void abort(char*);



/* Read new character fron input stream */
void getChar(){
    read(look);
}

/* Report an error */
void error(char* s) {
    // printf("%s\n", s);
    perror(s); 
}


/* Report an error and halt (return in C)  */
void abort(char *s) {
    perror(s);
    return;
}



/* Main Program */ 
int main(int argc, char *argv[]) {

    /* tab test */
    printf("%c\n", TAB);

    /* error test */
    char *p;
    p = "Error Test";
    error(p);

    /* abort test */
    p = "Abort Test";
    abort(p);
}

最佳答案

the C Standard :

7.22.4.1 The abort function

Synopsis

    #include <stdlib.h>
    _Noreturn void abort(void);

. . .

关于C - 错误冲突类型。定义了函数原型(prototype),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38425889/

相关文章:

function - 在Delphi中,如何从asm语句中调用私有(private)属性读取函数

javascript - 在我的 Controller 中,我有名为 "chiliClick"的函数。为什么不调用呢?

c++ - 推送到作为函数参数传递的队列

检查系统功能值

c - 当我有足够的空间并且数组中没有太多数据时,为什么在 C 中会出现运行时 #2 失败

c - 从文件中读取一个整数

c++ - 哪个更有效的内存明智 : static functions, 或立即删除的对象的功能?

C 函数指针

c++ - 用 printf 打印一个字符

c - Tilde C 无符号整数与有符号整数