游戏开发论坛

 找回密码
 立即注册
搜索
查看: 3476|回复: 6

PlaySound函数遇到问题

[复制链接]

13

主题

33

帖子

39

积分

注册会员

Rank: 2

积分
39
发表于 2005-12-19 13:45:00 | 显示全部楼层 |阅读模式
     我第一次用PlaySound函数,
PlaySound("1.wav",NULL,SND_ASYNC|SND_LOOP);
     编译时出错
f:\编程\INCLUDE\mmsystem.h(113) : error C2146: syntax error : missing ';' before identifier 'MMVERSION'
f:\编程\INCLUDE\mmsystem.h(113) : fatal error C1004: unexpected end of file found

这是说VC++系统文件有问题,但我重新安装VC++,还是出错,而且我其它程序加 mmsystem.h 头文件也没有出错。

     请高手们帮帮忙,谢谢。

3

主题

38

帖子

38

积分

注册会员

Rank: 2

积分
38
QQ
发表于 2005-12-19 17:06:00 | 显示全部楼层

Re:PlaySound函数遇到问题

检查一下前的代码,看看有没有漏分号。。
或者是括号不对称之类的。

3

主题

127

帖子

229

积分

中级会员

Rank: 3Rank: 3

积分
229
发表于 2005-12-19 17:23:00 | 显示全部楼层

Re:PlaySound函数遇到问题

有很多情况编译报错:missing";" 其实并不是真的确了分号, 很多情况是因为你的程序结构的问题  和  调用库文件没有成功而造成的

13

主题

33

帖子

39

积分

注册会员

Rank: 2

积分
39
 楼主| 发表于 2005-12-19 18:45:00 | 显示全部楼层

Re:PlaySound函数遇到问题

   可能是程序结构的问题,但我不知道问题在哪。
   我的程序加了一个  DXUtil.cpp,  这里面的头文件为:

#include <mmsystem.h>
#include <tchar.h>
#include <stdio.h>

也包含了  #include <mmsystem.h>
我单独编译DXUtil.cpp文件,不出错,但在主程序里面,如果不加 #include <mmsystem.h> ,就说 PlaySound函数没定义,如果加上 #include <mmsystem.h>,就出上面的  编译错误。

    请高手们指点,谢谢!

2

主题

21

帖子

27

积分

注册会员

Rank: 2

积分
27
发表于 2005-12-21 15:21:00 | 显示全部楼层

Re:PlaySound函数遇到问题

请仔细查一下MSDN

  Windows NT/2000/XP: Included in Windows NT 3.1 and later.
  Windows 95/98/Me: Included in Windows 95 and later.
  Header: Declared in Mmsystem.h; include Windows.h.
  Library: Use Winmm.lib.
  Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000/XP. Also supported by Microsoft Layer for Unicode
还要#include <windows.h>吧

7

主题

108

帖子

108

积分

注册会员

Rank: 2

积分
108
发表于 2005-12-21 17:27:00 | 显示全部楼层

Re:PlaySound函数遇到问题

开头加上#include <windows.h>

1

主题

41

帖子

45

积分

注册会员

Rank: 2

积分
45
发表于 2008-7-9 10:39:00 | 显示全部楼层

Re:PlaySound函数遇到问题

从 Project 菜单选择 Setting 选项,然后选取 Link 页面标签。从 Category 列表框中选择 General ,然后在 Object/Library Modules 添加 WINMM.LIB
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2026-1-22 01:27

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表