"expected primary-expression before ')' token" error, but can't see a syntax err

Hi,

I've been trying to resolve this issue for a month, and finally decided to seek help.

I have a nested "switch" statement in a function. Every time I try to compile, I get the error "expected primary-expression before ')' token". The error points to line 430, the inner switch statement itself, ["switch(Sub_Mode_Set_Timers){"]. For the life of me, I can't find any syntax problem on that line or in the code up to there from the beginning of the function. If I comment out that one line and its related "case" statements, the program compiles.

The program itself is a fan control system for a 3D printer that I am building for a friend.

To give you some idea of my (low level of) programming experience, I have done a little C++ and some other program languages over the years, but am little more than a novice with C++.

The error message and code are below. Please note that the code is nowhere near done. I am trying to establish the framework for how it will be structured first. I have not included the entire program, but the portions that I think may be relevant without posting hundreds of lines.

Any help would be greatly appreciated!

Thank you!
Charlie

Error Message

C:\Users\Owner\Documents\Arduino\Software\3D Printer Fan Control\Fan_Control_Software\John_Fan_Control_V1_00a_8_2_20\John_Fan_Control_V1_00a_8_2_20.ino: In function 'void MenuKeyRightPressed()':

John_Fan_Control_V1_00a_8_2_20:430:29: error: expected primary-expression before ')' token

   switch(Sub_Mode_Set_Timers)

                             ^

Program Code

//-- Modes
enum Mode
{
	Mode_Start_Pause_Resume_Clock,
	Mode_Set_Timers,
	Mode_Edit_Timers
};

enum Sub_Mode_Set_Timers 
{
	Sub_Mode_Set_Timers_Clear_Prev_Timers,
	Sub_Mode_Set_Timers_Enter_New_Timer,
	Sub_Mode_Set_Timers_Set_Power_Level,	
	Sub_Mode_Set_Timers_Add_Timer
};

enum Sub_Mode_Edit_Timers
{
	Sub_Mode_Edit_Timers_Add_Timer,
	Sub_Mode_Edit_Timers_Delete_Timer,
	Sub_Mode_Edit_Timers_Edit_Timer,
	Sub_Mode_Edit_Timers_Edit_Power
};		

// SNIP... code from enum to this function not shown

//***********************************************************************
// BUTTON CLICK HANDLER - RIGHT
//***********************************************************************

void MenuKeyRightPressed()
{
//	Some action
	bool Button_flag;
	Button_flag = true;
	snprintf(LCD_Row_1, 17, "Right Row 1     ");	//-- Store formatted version data for line 1
	snprintf(LCD_Row_2, 17, "Right Row 2     ");	//-- Store formatted version data for line 2
	PrintToLCD();


	switch(Mode)
	{ 		

		case Mode_Start_Pause_Resume_Clock:
		break;

		case Mode_Set_Timers:
		switch(Sub_Mode_Set_Timers)
		{

			case Sub_Mode_Set_Timers_Clear_Prev_Timers:
			break;
			
			case Sub_Mode_Set_Timers_Enter_New_Timer:
			break;
			
			case Sub_Mode_Set_Timers_Set_Power_Level:
			break;
			
			case Sub_Mode_Set_Timers_Add_Timer:
			break;
		}
		
		break;
		
		case Mode_Edit_Timers:
		break;
		
	}

	Button_flag = true;

}

What is a "Sub_Mode_Set_Timers"?

"Sub_Mode_Set_Timers" is the integer variable in an enum type. It evaluates to a 0, 1, 2 or 3, depending upon the enum names in sequence assigned below.

enum Sub_Mode_Set_Timers
{
	Sub_Mode_Set_Timers_Clear_Prev_Timers,
	Sub_Mode_Set_Timers_Enter_New_Timer,
	Sub_Mode_Set_Timers_Set_Power_Level,	
	Sub_Mode_Set_Timers_Add_Timer
};

Sub_Mode_Set_Timers" is the integer variable

No, "Sub_Mode_Set_Timers" is the name of an enum.

Sorry, you are right, it is the enum type-name.

But I just perceived that you may have meant "what is it FOR?" It is part of the menu system. If the user chooses "Set Timers", it goes into a subset of menus with further choices for setting the timers.

The point is that the enum is a type. You need a variable of that type in your switch statement. You apparently don't have one in the case the compiler is complaining about.

WildBill,

Ah, THAT'S what the issue is! I saw something similar done in a program that I had done some testing on, but in that case they must have declared a variable elsewhere in the program that I was unaware of. I thought that they were using the type name.

Many thanks to you and Formerly AWOL for setting me straight! I will implement it later tonight.