我正在研究 GCC 中的各种编译器选项,并在更改要使用的标准时观察变化。
$ gcc Q1.c -Wall -save-temps -o Q1
$ vi Q1.s
我看到其中一个操作码是
call __isoc99_scanf
现在当我用 C89 标准编译时
$gcc Q1.c -Wall -save-temps -std=c89 -o Q1
$ vi Q1.s
我看到的操作码是
call scanf
这两种形式的scanf
有什么区别?我将不胜感激任何我可以看到其来源的链接。
最佳答案
原因是严格遵循 c99 不允许一些现有的 GNU 扩展转换说明符。
在 glibc 2.17 中,在 libio/stdio.h
中有这样的注释:
/* For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[
GNU extension which conflicts with valid %a followed by letter
s, S or [. */
extern int __REDIRECT (fscanf, (FILE *__restrict __stream,
const char *__restrict __format, ...),
__isoc99_fscanf) __wur;
extern int __REDIRECT (scanf, (const char *__restrict __format, ...),
__isoc99_scanf) __wur;
extern int __REDIRECT_NTH (sscanf, (const char *__restrict __s,
const char *__restrict __format, ...),
__isoc99_sscanf);
关于c - __isoc99_scanf 和 scanf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16376341/