__函数声明后的asm(“isoc99扫描”)
我在预处理的C代码中看到了以下代码。asm在函数声明之后做什么__函数声明后的asm(“isoc99扫描”),c,gcc,assembly,inline-assembly,function-declaration,C,Gcc,Assembly,Inline Assembly,Function Declaration,我在预处理的C代码中看到了以下代码。asm在函数声明之后做什么 extern int scanf (const char *__restrict __format, ...) __asm__ ("" "__isoc99_scanf"); 显然,它使函数调用编译为“call uu isoc99_scanf”而不是“call scanf”。这是C/GCC标准语法吗?我刚刚在stdio common/isoc99\u scanf.C下的glibc中找到了它的实现,如下所示 /* Copyright
extern int scanf (const char *__restrict __format, ...) __asm__ ("" "__isoc99_scanf");
显然,它使函数调用编译为“call uu isoc99_scanf”而不是“call scanf”。这是C/GCC标准语法吗?我刚刚在
stdio common/isoc99\u scanf.C
下的glibc
中找到了它的实现,如下所示
/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#include <stdarg.h>
#include <stdio.h>
#include <libioP.h>
/* Read formatted input from stdin according to the format string FORMAT. */
int
__isoc99_scanf (const char *format, ...)
{
va_list arg;
int done;
va_start (arg, format);
done = __vfscanf_internal (stdin, format, arg, SCANF_ISOC99_A);
va_end (arg);
return done;
}
#if defined __USE_ISOC99 && !defined __USE_GNU \
&& (!defined __LDBL_COMPAT || !defined __REDIRECT) \
&& (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)
# ifdef __REDIRECT
/* 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 (sscanf, (__const char *__restrict __s,
__const char *__restrict __format, ...),
__isoc99_sscanf) __THROW;
# else
extern int __isoc99_fscanf (FILE *__restrict __stream,
__const char *__restrict __format, ...) __wur;
extern int __isoc99_scanf (__const char *__restrict __format, ...) __wur;
extern int __isoc99_sscanf (__const char *__restrict __s,
__const char *__restrict __format, ...) __THROW;
# define fscanf __isoc99_fscanf
# define scanf __isoc99_scanf
# define sscanf __isoc99_sscanf
# endif
#endif
你在手册里查过吗?这肯定是编译器特有的语法。类似的语法。@MartinRosenau:这正是为asm/链接设置符号名的GNU C语法。
“foo”
只是毫无意义的字符串连接,可能是C预处理器的结果。@MartinRosenau-您提供的链接指向一个相当旧的gcc文档版本(4.4)。这句话说的差不多,但可能更清楚一点。