Why can I use gets() in gcc -std=c11?

前端 未结 3 1805
余生分开走
余生分开走 2021-01-02 00:43

The gets() function has been removed from the C language. No such function exists in the standard.

Yet I compile the following code:

#in         


        
3条回答
  •  梦谈多话
    2021-01-02 01:09

    update this may not be an answer to the question, I try to make it informational.

    I happened to find that gcc mentioned gets is not following C11 standard for some library issue glibc 2.16.

    See gcc supporting status of C11: https://gcc.gnu.org/wiki/C11Status

    But I cannot find the definition of "library issue" and current status for other versions of glibc.

    So I tried on my machine ubuntu16.04 with gcc version 5.3.1 20160413, glibc version Ubuntu GLIBC 2.23 We can get enough warning on compile time, but it's still OK to execute the output object file for "Backwards compatibility".

    warning: implicit declaration of function ‘gets’ [-Wimplicit-function-declaration]
    warning: the `gets' function is dangerous and should not be used.
    

提交回复
热议问题