Something weird with array declarations

Hey, I'm trying to do somethign really simple but why it's not working I have no idea. Here's a section of the code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
void Hardware_test::report(int successCount[], int errorCount[], int totalFailedConnectionAttempts, int seperateDisconnects, const int numberOfOperations)
{
        static int PreviousSuccessCount[5] = { 0 };
	static int PreviousErrorCount[5] = { 0 };
	::std::string errorMessage = " ";
	//float acceptableFailToSuccessRatio = config_.get<float>(key_acceptableFailToSuccessRatio);
	
	
	//TODO: figure out why the hell this doesn't work.
	for(int i=0; i<5; i++){
		if(1 < ((errorCount[i]-previousErrorCount[i])/(successCount[i]-previousSuccessCount[i]))){
			if(errorChecking==true){
				error_=true;
				errorMessage = "The ratio of unsuccessful to successful communication attempts was too high";
			}
		}
	}


I'm getting the following errors:

error: 'previousErrorCount' was not declared in this scope
error: 'previousSuccessCount' was not declared in this scope
error: 'errorChecking' was not declared in this scope

At the beginning of a different function I have
1
2
static int successCount[numberOfOperations] = { 0 };
static int errorCount[numberOfOperations] = { 0 };


and this seems to work fine. I really have no idea what is going on, but I figure it has to be me doing something stupid, can anyone see it?

Cheers,
TheMeerkat
The Size of your arrays is 5 and you only put 1 value in there. I believe that is the problem. If not then I am dumb. If you don't want to have values in the rest then just do this.

1
2
static int PreviousSuccessCount[5] = { 0, NULL, NULL, NULL, NULL };
	static int PreviousErrorCount[5] = { 0, NULL, NULL, NULL, NULL };
From what I understand the way I have done it should initialise all elements within the array as 0. But I had thought of this and tried to compile it with those lines changed to

1
2
static int PreviousSuccessCount[5] = { 0, 0, 0, 0, 0 };
static int PreviousErrorCount[5] = { 0, 0, 0, 0, 0 };


But it still wouldn't work. Plus if that had of been the issue would the error not have been that the arrays were not initialised instead of not declared?
PreviousSuccessCount has a capital P at the start.
previousSuccessCount does not.

PreviousErrorCount has a capital P at the start.
previousErrorCount does not.

errorChecking simply does not exist.
Last edited on
Thanks, I can't believe I didn't see that.
Topic archived. No new replies allowed.