473,396 Members | 1,712 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

DirectX dsutil.cpp error

I've been trying to compile a program, everything is going fine until i get this little error:
Expand|Select|Wrap|Line Numbers
  1. ------ Build started: Project: Play_Sound, Configuration: Debug Win32 ------
  2. Compiling...
  3. dsutil.cpp
  4. c:\documents and settings\###\my documents\visual studio 2008\projects\play_sound\play_sound\dsutil.cpp(686) : error C2065: 'i' : undeclared identifier
  5. c:\documents and settings\###\my documents\visual studio 2008\projects\play_sound\play_sound\dsutil.cpp(687) : error C2065: 'i' : undeclared identifier
  6. Build log was saved at "file://c:\Documents and Settings\###\My Documents\Visual Studio 2008\Projects\Play_Sound\Play_Sound\Debug\BuildLog.htm"
  7. Play_Sound - 2 error(s), 0 warning(s)
  8. ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
  9.  
]

And the exact lines that have this problem are
Expand|Select|Wrap|Line Numbers
  1. LPDIRECTSOUNDBUFFER CSound::GetFreeBuffer()
  2. {
  3.     if( m_apDSBuffer == NULL )
  4.         return FALSE; 
  5.  
  6.     for( DWORD i=0; i<m_dwNumBuffers; i++ )
  7.     {
  8.         if( m_apDSBuffer[i] )
  9.         {  
  10.             DWORD dwStatus = 0;
  11.             m_apDSBuffer[i]->GetStatus( &dwStatus );
  12.             if ( ( dwStatus & DSBSTATUS_PLAYING ) == 0 )
  13.                 break;
  14.         }
  15.     }
  16.  
  17.     if( i != m_dwNumBuffers )
  18.         return m_apDSBuffer[ i ];
  19.     else
  20.         return m_apDSBuffer[ rand() % m_dwNumBuffers ];
  21. }
  22.  
the frustrating part is that it isn't my code...
and it's too complicated for me to figure out, i was thinking it was something with the braces and the "i" not being a identified in the "if" statement, although the program worked when i changed their location, there was no sound :(

kind regards,
Netwatcher.
Jan 19 '09 #1
4 3086
JosAH
11,448 Expert 8TB
Change your lines #5 and #6 to this:

Expand|Select|Wrap|Line Numbers
  1. DWORD i;
  2. for( i=0; i<m_dwNumBuffers; i++ ) 
  3.  
kind regards,

Jos
Jan 19 '09 #2
Well it did exactly what i did :p
But! it helped me find the real bug...
debugging is a nasty process!
Thanks :D
Jan 19 '09 #3
JosAH
11,448 Expert 8TB
@Netwatcher
Better be prepared then because this was an easy compile time bug: when you define a variable in the header part of a for loop that variable only exists in the scope of the for header and body; outside of that scope that variable simply doesn't exist. Note that very old C++ compilers made the variable exist in the block part following the for loop body; that was just a silly decision and has been corrrected.

kind regards,

Jos
Jan 19 '09 #4
("Beginning Game Programming, Second edition"-chapter 9)
I take it back...
I'm using IBM T42 Thinkpad with with default hardware & newest Audio Drive
The program loads A-okay but no sound whatever what i do :( can it be that
My Audio hardware is not compatible with the DXaudio(using dsutil.cpp/h) lib? (i CAN play wav files with normal audio players)
Jan 20 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: kastillo | last post by:
Im trying to install directx 9.0 c , but i simply cant . When i run the installer it just says " The installed components are ready to use". This is the report on directx.log : 09/10/05...
2
by: Michael Mayer | last post by:
First of all, sorry for the cross-post. Seems like there should be a managed directx newsgroup. I'm trying to open the following sample application that comes with the DirectX SDK....
4
by: Junaid Hussain | last post by:
Hi, I am thinking about developing a 3D pool game in C# using DirectX, however when I compile a C# at the command prompt using; csc PoolGame.cs , I get the following error message; The type or...
9
by: Mike P | last post by:
Problems, problems... Im trying to create DirectX Projects within C# and to also look at the latest DirectX C# Samples. I have just installed MS Visual C# .net Standard Edition on my Windows...
0
by: wraith | last post by:
Hi to all, I would just like to ask a simple question... Could Managed DirectX 9 (SDK Summer 2004) be used in MVC++ 2003? I ask this question coz, I get an error when using Managed DirectX in...
2
by: Richard | last post by:
When I try to run a VB DirectX9 application that I created with the teapot template (and don't ad any code) it comes up with the dialog box: "Microsoft Managed DirectX This pre-release version of...
0
by: Harvey Cohen | last post by:
Hello all, I have some C# code that implements calls to DirectX.DirectSound. It compiles under both VS .NET 2003 and VS 2005 and runs under VS .NET 2003 and VS 2005 on a Compaq laptop (Windows...
2
by: untitled | last post by:
i included the following line to VC++ after i installed the directx SDK and platform SDK. #include "DShow.h" i configured c directories for the include and lib to both directx SDX and platform...
11
by: raylopez99 | last post by:
I just downloaded the apparently free SDK for DirectX 9, all 200+ MB of it, but as I read about WPF I wonder: is DirectX obsolete? Should I even bother learning how to use it? After all, the end...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.