求助:关于编译错误游离等

gold518 2007-11-19 09:55:30
以下程序:
* sndrec.c */
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <stdlib.h>
#include <stdio.h>
#include <linux/soundcard.h>

#define LENGTH 3
#define RATE 8000
#define SIZE 8
#define CHANNELS 1
char buf[LENGTH*RATE*SIZE*CHANNELS/8];

int main()
{
int fd;
int arg;
int status;
fd = open("/dev/dsp", O_RDWR);
if (fd < 0) {
perror("open of /dev/dsp failed");
exit(1);
}
arg = SIZE;
status = ioctl(fd, SOUND_PCM_WRITE_BITS, &arg);
if (status == -1)
perror("SOUND_PCM_WRITE_BITS ioctl failed");
if (arg != SIZE)
perror("unable to set sample size");
arg = CHANNELS;
status = ioctl(fd, SOUND_PCM_WRITE_CHANNELS, &arg);
if (status == -1)
perror("SOUND_PCM_WRITE_CHANNELS ioctl failed");
if (arg != CHANNELS)
perror("unable to set number of channels");
arg = RATE;
status = ioctl(fd, SOUND_PCM_WRITE_RATE, &arg);
if (status == -1)
perror("SOUND_PCM_WRITE_WRITE ioctl failed");
while (1) {
printf("Say something:\n");
status = read(fd, buf,sizeof(buf) );
if (status != sizeof(buf))
perror("read wrong number of bytes");

printf("You said:\n");
status = write(fd, buf, sizeof(buf));
if (status != sizeof(buf))
perror("wrote wrong number of bytes");
status = ioctl(fd, SOUND_PCM_SYNC, 0);
if (status == -1)
perror("SOUND_PCM_SYNC ioctl failed");
}
return 0;
}

我用的FC6编译出错:
sndrec.c:1: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘.’ token
In file included from sndrec.c:2:
/usr/include/unistd.h:325: 错误:expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/unistd.h:331: 错误:expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/unistd.h:469: 错误:expected declaration specifiers or ‘...’ before ‘size_t’
In file included from sndrec.c:2:
/usr/include/unistd.h:566: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘confstr’
/usr/include/unistd.h:738: 错误:expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/unistd.h:774: 错误:expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/unistd.h:821: 错误:expected declaration specifiers or ‘...’ before ‘size_t’
In file included from sndrec.c:2:
/usr/include/unistd.h:843: 错误:expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/unistd.h:850: 错误:expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/unistd.h:861: 错误:expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/unistd.h:863: 错误:expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/unistd.h:881: 错误:expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/unistd.h:882: 错误:expected declaration specifiers or ‘...’ before ‘size_t’
In file included from sndrec.c:6:
/usr/include/stdlib.h:140: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__ctype_get_mb_cur_max’
/usr/include/stdlib.h:455: 错误:expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/stdlib.h:485: 错误:expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/stdlib.h:487: 错误:非空的实参操作数号越界(实参 1,操作数 4)
/usr/include/stdlib.h:589: 错误:expected ‘)’ before ‘__size’
/usr/include/stdlib.h:591: 错误:expected ‘)’ before ‘__nmemb’
/usr/include/stdlib.h:600: 错误:expected declaration specifiers or ‘...’ before ‘size_t’
In file included from /usr/include/stdlib.h:612,
from sndrec.c:6:
/usr/include/alloca.h:33: 错误:expected ‘)’ before ‘__size’
In file included from sndrec.c:6:
/usr/include/stdlib.h:617: 错误:expected ‘)’ before ‘__size’
/usr/include/stdlib.h:622: 错误:expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/stdlib.h:622: 错误:expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/stdlib.h:776: 错误:expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/stdlib.h:776: 错误:expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/stdlib.h:777: 错误:非空的实参操作数号越界(实参 1,操作数 5)
/usr/include/stdlib.h:781: 错误:expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/stdlib.h:781: 错误:expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/stdlib.h:782: 错误:非空的实参操作数号越界(实参 1,操作数 4)
/usr/include/stdlib.h:854: 错误:expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/stdlib.h:857: 错误:expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/stdlib.h:861: 错误:expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/stdlib.h:865: 错误:expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/stdlib.h:874: 错误:expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/stdlib.h:878: 错误:expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/stdlib.h:885: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘mbstowcs’
/usr/include/stdlib.h:888: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘wcstombs’
In file included from /usr/include/_G_config.h:44,
from /usr/include/libio.h:32,
from /usr/include/stdio.h:72,
from sndrec.c:7:
/usr/include/gconv.h:72: 错误:expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/gconv.h:88: 错误:expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/gconv.h:97: 错误:expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/gconv.h:174: 错误:expected specifier-qualifier-list before ‘size_t’
In file included from /usr/include/stdio.h:72,
from sndrec.c:7:
/usr/include/libio.h:328: 错误:expected specifier-qualifier-list before ‘size_t’
/usr/include/libio.h:360: 错误:expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/libio.h:369: 错误:expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/libio.h:485: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘_IO_sgetn’
In file included from sndrec.c:7:
/usr/include/stdio.h:308: 错误:expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/stdio.h:315: 错误:expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/stdio.h:357: 错误:expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/stdio.h:359: 错误:格式字符串实参不是字符串玵型
/usr/include/stdio.h:361: 错误:expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/stdio.h:610: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘fread’
/usr/include/stdio.h:616: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘fwrite’
/usr/include/stdio.h:638: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘fread_unlocked’
/usr/include/stdio.h:640: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘fwrite_unlocked’
sndrec.c: 在函数 ‘main’ 中:
sndrec.c:44: 错误:程序中有游离的 ‘\302’
sndrec.c:44: 错误:程序中有游离的 ‘\240’
sndrec.c:44: 错误:程序中有游离的 ‘\302’
sndrec.c:44: 错误:程序中有游离的 ‘\240’
sndrec.c:44: 错误:程序中有游离的 ‘\302’
sndrec.c:44: 错误:程序中有游离的 ‘\240’
sndrec.c:44: 错误:提供给函数 ‘read’ 的实参太多
sndrec.c:49: 错误:提供给函数 ‘write’ 的实参太多
...全文
2884 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
wxf722 2008-07-30
  • 打赏
  • 举报
回复
你是直接复制粘贴源代码到Linux的文件里的对么?
如果是,你用vi看下你的源代码,估计你文件的开头少了几个字符~~
你仔细看下~~
wxf722 2008-07-30
  • 打赏
  • 举报
回复
假设你的c源代码名为test.c
终端下输入gcc -p -g -o test test.c
应该能编译通过,当然,前提是你在windows下这个程序是编译通过的。
我刚才也遇到了你这个问题,报出的错误大致相同,我的程序在windows下是编译运行正常的。
刚才输入了gcc -p -g -o test test.c,发现编译通过了。。。
虽然不知道怎么通过的,但是你可以尝试下~~
fuqd273 2008-07-30
  • 打赏
  • 举报
回复
用ultraedit转一下格式也可以的。支持windows->unix的文件转化。
fuqd273 2008-07-30
  • 打赏
  • 举报
回复
怎么是* sndrec.c */ ?
不是/* sndrec.c */ ???
wxf722 2008-07-30
  • 打赏
  • 举报
回复
用手敲?不会吧,那我几百行的程序也从敲遍?
为什么会出现上面那么多错误呢?
在windows下编译运行都很正常阿~~
dooluby 2008-07-30
  • 打赏
  • 举报
回复
呵呵,你用vi打开看看,是不是每行结束有^M这样的字符串。如果有的话,转换一下。。

或者用:1,$ s/^M//g 替换一下。
dooluby 2008-07-30
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 fuqd273 的回复:]
用ultraedit转一下格式也可以的。支持windows->unix的文件转化。
[/Quote]

我和fuqd273的意见一致,呵呵。。。有很大的因素是因为你便宜的时候文件格式是Windows格式。
chengwei19851026 2008-06-11
  • 打赏
  • 举报
回复
哥哥,你别偷懒复制粘贴。用手敲
vf6.0,要考二级没系统的下哈 Microsoft Visual FoxPro 6.0 for Windows 的常见问题 这些是有关 Microsoft Visual FoxPro 最常见的问题。在您求助 Microsoft 产品支持服务之前,请先查阅这张列表。 若想打印这些附注,请从“文件”菜单中选择“打印”命令。此文档分为以下四部分: --------------------------------------------------------------------- 部分 1. 技术支持与市场 部分 2. Visual FoxPro 6.0 新增功能 部分 3. 从其他版本的 FoxPro 和 Visual FoxPro 中移植 部分 4. Visual FoxPro 常见问题 --------------------------------------------------------------------- 部分 1. 技术支持与市场 问题 1-1: 从何处可以获得产品的更新版本? 答案: 在 Visual FoxPro 的 Web 站点上即可获得产品的更新信息,其中包括有关 Service Pack 和更新的示例、向导及其他代码的信息,该站点的网址为: www.microsoft.com/vfoxpro 请定期查看该网站,以便下载产品的最新版本。 问题 1-2: 从何处可以得到有关 Visual FoxPro 的详细资料? 答案: 通过 Microsoft Visual FoxPro Web 站点是随时获得各种最新产品发布信息的最佳途径。在此站点上不仅有新的产品公告,而且还提供了产品的更新信息、技术文章、白皮书、专业开发人员设计的优秀示例、会议公告、以及与其他许多 FoxPro web 站点的各种链接。 问题 1-3: 如何获得技术支持,以及如何报告软件错误? 答案: Microsoft Visual FoxPro Web 站点已经链接到了多种联机支持选项,其中包括覆盖面广阔的有关所有产品 Microsoft Knowledge Base(Microsoft 知识库)。您还可以阅读一份有关常见问题的清单。除联机支持之外,还可以直接通过电话获得技术支持。“帮助”菜单中的选项可列出技术支持的电话号码。这些电话号码也可用于报告产品中的错误。 问题 1-4. 什么是 Knowledge Base?如何使用它? 答案: Knowledge Base 是内容广泛的论文集,覆盖了如何使用产品的各种特性、已知的软件错误及其解决方案或回避的方法、以及其他有助于使用各种 Microsoft 产品的有用信息。通过以下站点可访问整个 Knowledge Base: support.microsoft.com 问题 1-5: 是否会有 Visual FoxPro 6.0a? 答案: Microsoft 公司一向承诺为用户提供高质量的产品。如果确实需要,我们将提供 Visual FoxPro 6.0 的错误修订版。但是,修订版不会使用 6.0a 版的形式。Visual FoxPro 6.0 中任何错误的修正都将包含在 Visual Studio Service Pack 中。同时还会在 Visual FoxPro 的 www.microsoft.com/vfoxpro 或 Visual Studio 的www.microsoft.com/vstudio 的 Web 站点上发布修订公告。 问题 1-6: Microsoft 公司为应用程序的开发提供了一些优秀的解决方案。怎样才能知道应该向客户推荐和使用哪种产品? 答案: 在选择适用某项任务的产品时,需要考虑多方面的因素。Microsoft Visual FoxPro web 站点上有一份优秀的策略背景论文,它比较了 Visual FoxPro、Visual Basic、SQL Server 和 Access 等 Microsoft 产品之间的不同。 问题 1-7: 哪里可以找到 Visual FoxPro 的使用示例? 答案: Visual FoxPro 6.0 产品中带有丰富的示例,其中有一些是针对 6.0 版特有功能的新示例。与 Visual FoxPro 以前的版本不同,这些示例将与所有 Visual Studio 示例安装在一起。您必须运行 MSDN Library 的“自定义”安装来安装这些示例。在 Visual FoxPro 中可使用新的 HOME(2) 函数方便地找到已安装示例的位置。 除了产品中所自带的示例外,Microsoft Visual FoxPro web 站点还将经常提供新的示例。

23,132

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧