2013-05-04 35 views
7

我正在研究GCC中的各種編譯器選項,並觀察當我對要使用的標準進行更改時所做的更改。__isoc99_scanf和scanf

$ 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 

什麼是這兩個fo的區別有效期scanf?任何我可以看到他們的來源的鏈接將受到高度讚賞。

+0

感謝@Mat,我真的需要這些資本是工作.. :) – ArunMKumar 2013-05-04 15:22:41

回答

8

原因是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); 
6

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 
+0

所以我推斷它更多的兼容性? – ArunMKumar 2013-05-07 04:37:19