我正在研究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
有什么不同?任何链接,我可以看到他们的来源,将非常感谢。
发布于 2013-05-05 00:27:07
原因是严格遵循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);
发布于 2013-05-04 23:43:58
scanf(3) manual提到了c99中引入的几个类型修饰符:
j As for h, but the next pointer is a pointer to an intmax_t or a uintmax_t. This modifier was introduced in C99
t As for h, but the next pointer is a pointer to a ptrdiff_t. This modifier was introduced in C99.
z As for h, but the next pointer is a pointer to a size_t. This modifier was introduced in C99.
a (C99) Equivalent to f
https://stackoverflow.com/questions/16376341
复制相似问题