0
这里是简单echo.c源代码:错误而编译宏__COPYRIGHT用gcc
#include <sys/cdefs.h>
#ifndef lint
__COPYRIGHT(
"@(#) Copyright (c) 1989, 1993\n\
The Regents of the University of California. All rights reserved.\n");
#endif /* not lint */
#ifndef lint
#if 0
static char sccsid[] = "@(#)echo.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: echo.c,v 1.7 1997/07/20 06:07:03 thorpej Exp $");
#endif
#endif /* not lint */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main __P((int, char *[]));
int
main(argc, argv)
int argc;
char *argv[];
{
/*
*main code with no error at all
*/
}
当用gcc 4.4.6编译它,它报告错误:
echo.c:4: error: expected declaration specifiers or â...â before string constant
echo.c:3: warning: data definition has no type or storage class
echo.c:12: error: expected declaration specifiers or â...â before string constant
echo.c:12: warning: data definition has no type or storage class
3号线和4是__COPYRIGHT宏。 第12行是__RCSID宏。
如果我删除这两个宏,它会编译成功并正确运行。
一些谷歌搜索后,我知道这两个宏是在sys/cdefs.h中定义的,它们是某种评论消息。
但为什么它不会在gcc中编译?
啊哈!这让我疯狂,谢谢。 – saulspatz 2014-10-09 19:34:48