Enum class problems

I'm having some issues getting an enum class working in my program. I declare it in a header file, and am trying to use it in the associated .cpp file. No matter what I do, I get the same error saying that wave (the name of the enum) is not a class or namespace. I'm sure it's something really simple that I'm missing, but I just don't know enough to figure out what it is. Any help would be greatly appreciated.

vco.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#ifndef VCO_H_
#define VCO_H_

#define fineFreqSteps		256
#define coarseFreqSteps		256
#define pulsewidthSteps 	256

enum class Wave : int {sine, triangle, ramp, square};

class Vco {
	int fineFreq, coarseFreq, pulsewidth;
	int fineFreqAddr, coarseFreqAddr, pulsewidthAddr, switchAddr, iicBus, synthBoardAddr;
	int fineFreqRdac, coarseFreqRdac, pulsewidthRdac;
	bool syncEnable;
	Wave waveSelect;


	public:
		Vco (int, int, int, int, int, int, int, int, int);
		void setFineFreq (int);
		void setCoarseFreq (int);
		void setPulsewidth (int);
		void incrementFineFreq (int);
		void incrementCoarseFreq (int);
		void incrementPulsewidth (int);
		int getFineFreq ();
		int getCoarseFreq ();
		int getPulsewidth ();
		void setWave (Wave);
		Wave getWave ();
		void setSync (bool);
		bool getSync ();

	private:
		void updateFineFreqDigipot ();
		void updateCoarseFreqDigipot ();
		void updatePulsewidthDigipot ();
		void updateSwitch ();
};

#endif /* VCO_H_ */ 


vco.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include "Vco.h"

Vco::Vco(int fineFreqAddr, int coarseFreqAddr, int pulsewidthAddr, int switchAddr, int fineFreqRdac, int coarseFreqRdac, int pulsewidthRdac, int synthBoardAddr, int iicBus) {
	this->fineFreqAddr = fineFreqAddr;
	this->coarseFreqAddr = coarseFreqAddr;
	this->pulsewidthAddr = pulsewidthAddr;
	this->switchAddr = switchAddr;
	this->fineFreqRdac = fineFreqRdac;
	this->coarseFreqRdac = coarseFreqRdac;
	this->pulsewidthRdac = pulsewidthRdac;
	this->synthBoardAddr = synthBoardAddr;
	this->iicBus = iicBus;
	this->fineFreq = 0;
	this->coarseFreq = 0;
	this->pulsewidth = 0;
	this->waveSelect = Wave::sine;
	updateSwitch();
}


error log - The line numbers here are 12 more than their respective lines in the code snippets above.
21:41:47 **** Incremental Build of configuration Default for project Synth Main Board ****
make all 
rm -f project.hex
Creating object file for app.cpp
In file included from Vco.cpp:13:0,
                 from app.cpp:19:
Vco.h:20:1: warning: scoped enums only available with -std=c++11 or -std=gnu++11 [enabled by default]
Vco.h:20:19: warning: scoped enums only available with -std=c++11 or -std=gnu++11 [enabled by default]
In file included from app.cpp:19:0:
Vco.cpp: In constructor 'Vco::Vco(int, int, int, int, int, int, int, int, int)':
Vco.cpp:28:21: error: 'Wave' is not a class or namespace
Vco.cpp: In member function 'void Vco::updateSwitch()':
Vco.cpp:184:58: error: 'Wave' is not a class or namespace
Vco.cpp:184:95: error: 'Wave' is not a class or namespace
Vco.cpp:184:134: error: 'Wave' is not a class or namespace
Vco.cpp:184:175: error: 'Wave' is not a class or namespace
make: *** [project_build/app.o] Error 1

21:41:47 Build Finished (took 119ms)
Looking at the warnings, I'd guess you need to compile with -std=c++11 to get access to enum classes unless the "enabled by default" means they are in fact enabled.
I guess that shows me for assuming enabled by default means that it compiles with that by default... Adding the flag to the makefile made everything work perfectly.
Topic archived. No new replies allowed.