Very strange error

  • Follow


Hey, I figured my first post would be something grand, but instead I
have this really odd issue.  I'm using VC++ 6.0 in XP Home (at work,
don't ask..I'm asking to move to something different and new).  I'll
just paste my code:

"""
void CCylinderControlDlg::OnOK_Clicked()
{
	CString strOne;
	CString strTwo;


	m_editOne.GetWindowText(strOne);
	m_editTwo.GetWindowText(strTwo);

	if((atof(strOne) > 0) && (atof(strOne) < 1) && (atof(strTwo) > 0)){
		Interval = atof(strOne);
		m_LengthOfTime = atof(strTwo);
		Peak = Interval/2;
		Run_Summer();

	}
	else{
		AfxMessageBox("Please enter valid data");
		CDialog::OnCancel();
	}


}
double* CCylinderControlDlg::Run_Summer(){

	m_test=(SAMPLE_RATE * m_LengthOfTime) + 1;

	m_test2=Peak*SAMPLE_RATE;

	double* buffer2;
	buffer2 = new double [m_test];

	for(int i = 0 ; i < m_test2 ; i++){			// start rising edge of triangle
		buffer2[i] = (i/SAMPLE_RATE) * MAX_PEAK_VOLTAGE;
	}
	for(i = 0 ; i < m_test2 ; i++){			// start falling edge of triangle
		buffer2[i] = (Peak - i/SAMPLE_RATE) * MAX_PEAK_VOLTAGE;
	}

	return buffer2;
}
"""

The error I'm getting is "C:\Documents and Settings\stevenr\My
Documents\Software Related\Cylinder Control\Cylinder
ControlDlg.cpp(201) : error C2059: syntax error : '='"

And this is for the following lines:

1. m_test=(SAMPLE_RATE * m_LengthOfTime) + 1;
2. m_test2=Peak*SAMPLE_RATE;
3. buffer2[i] = (i/SAMPLE_RATE) * MAX_PEAK_VOLTAGE;
4. buffer2[i] = (Peak - i/SAMPLE_RATE) * MAX_PEAK_VOLTAGE;

SAMPLE_RATE has been pound defined as 10000, MAX_PEAK_VOLTAGE is 5,
m_LengthOfTime has been atof()'ed from a CString from an EditBox on a
dialog, so has Peak.  I'm really wondering where this error is coming
from...I've tried to cast each of these to the correct type.  I pasted
the only two functions that I've written so far today, and I can't get
paste this blasted error..it's boggling my mind!  I've cleared all of
intermediate files, rebooted, rearranged, etc etc etc...and can't
understand why I'm not able to assign a value to a variable...

Anyway, any help would be appreciated.  Thanks.

-Ben

0
Reply henrybg (38) 5/19/2005 6:04:11 PM

Benry wrote:
> [irrelevant code redacted\
> """
> 
> The error I'm getting is "C:\Documents and Settings\stevenr\My
> Documents\Software Related\Cylinder Control\Cylinder
> ControlDlg.cpp(201) : error C2059: syntax error : '='"
> 

What is line 201?  We can't tell from your sample clip.
0
Reply no.spam9 (2339) 5/19/2005 6:21:32 PM


Benry wrote:

> m_test=(SAMPLE_RATE * m_LengthOfTime) + 1;

What does SAMPLE_RATE look like? This?

#define SAMPLE_RATE 20;

Note the ; on the end. It shouldn't be there, because # things evaluate
before the core C++ language engages.

-- 
  Phlip
  http://www.c2.com/cgi/wiki?ZeekLand


0
Reply phlip_cpp (3649) 5/19/2005 6:27:25 PM

They look exactly like this:

//#define MAX_PEAK_VOLTAGE = 5
#define SAMPLE_RATE = 10000

Note the comment, I just added that because I started moving on.
But...I got the same error on this line:

if(counter_for_wave < (m_LengthOfTime*SAMPLE_RATE)){

WTF!!!  There isn't even an equals sign on this line!!!!  I don't get
it!

0
Reply henrybg (38) 5/19/2005 7:15:03 PM

I get this error four times, all with the line numbers of what I've
annotated above in the list 1-4.

0
Reply henrybg (38) 5/19/2005 7:16:07 PM

Benry wrote:
> They look exactly like this:
> 
> //#define MAX_PEAK_VOLTAGE = 5
> #define SAMPLE_RATE = 10000

Should be:

#define SAMPLE_RATE 10000

Remember the defines are translated by the preprocessor. I.e.

#define SAMPLE_RATE = 10000 would be

if(counter_for_wave < (m_LengthOfTime* = SAMPLE_RATE)){

Have you considered using const's instead? E.g.

const unsigned SAMPLE_RATE = 10000;

This will be handled by the compiler instead of the preprocessor. At 
least you will get more meaningfull error messages from the compiler :-)

HTH.

-- 
Peter
0
Reply peter.kragh_fjern 5/19/2005 7:22:21 PM

wow, I totally missed that.  It's been a long week, I appreciate the
help.  Thanks.

-Ben

0
Reply henrybg (38) 5/19/2005 7:35:49 PM

6 Replies
24 Views

(page loaded in 0.144 seconds)


Reply: