conflicting types for getline function

前端 未结 2 2086
误落风尘
误落风尘 2021-01-25 23:13

I have a function for getline function in my code block.But while compiling the make file i get the following error:

cc -DMAIN   -c -o terp.o terp.c
terp.c:130:1         


        
相关标签:
2条回答
  • 2021-01-25 23:57

    There are at least three possible solutions.

    1. As getline() is not in standard c library, but in POSIX (and GLIBC), there could be switch to disable its extension (they enabled by default in GCC). Try compiling your source with command cc -DMAIN -std=c99 -c -o terp.o terp.c.

    2. If you need POSIX extensions, you have to rename your getline() function to something else.

    3. Remove #include <stdio.h> from your source, this error message will disappear. But you may become confused if POSIX's getline() is used in your source code, as it will be replaced by yours.

    0 讨论(0)
  • 2021-01-25 23:57

    You need to choose a different name for your getline function, because there already is a getline in the standard clib.

    0 讨论(0)
提交回复
热议问题