?
Solved

MACRO Problem

Posted on 2000-02-10
2
Medium Priority
?
174 Views
Last Modified: 2010-04-10
I have defined a macro and have encountered a problem using it. Below is the macro I have defined.

#define BULLET PlaySound("bullet.wav",NULL,SND_FILENAME|SND_ASYNC)

I then try to use it and is successful.

void main()
{
...
    BULLET; // run the macro
...
}

The above works and I heard the sound of one bullet.
However, when I tried to run the macro twice consecutively, it is unsuccessful.

void main()
{
...
    BULLET; // run macro
    BULLET; // another time
...
}

I expect to hear two bullets sound but I only hear one bullet sound.

Why?

hongjun
0
Comment
Question by:hongjun
2 Comments
 
LVL 22

Accepted Solution

by:
nietod earned 40 total points
ID: 2510251
This has nothing to do with macros, the problem occurs if you do

PlaySound("bullet.wav",NULL,SND_FILENAME|SND_ASYNC);
PlaySound("bullet.wav",NULL,SND_FILENAME|SND_ASYNC);

right?

the problem is that you try to start 2nd sound before the first one has finsihed.  Don't play asynchronously or place a wait between the two attempts to play.
0
 
LVL 33

Author Comment

by:hongjun
ID: 2510305
Well done!!!

hongjun
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

589 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question