Compile Error in Template - missing ;


Normally this would be a quick fix, but this is really becoming frustrating and I need a fresh pair of eyes. This builds fine in the DLL, but when the test app is building (statically link to the DLL), as you can see this error pops up in main. I've double checked all my DLL exports and that all the headers that are exported are also copied to the Test Projects directory. I've even added some extra exports (not needed) just to be sure.

I've added overkill as far as includes goes, I had another project, console that ran this same code (non DLL) and it worked fine, no problem with the -int assumed or the semi colon error (and with less includes). I checked to make sure that the Header is included.

Line 118 is first error.


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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#ifndef Topics_h__
#define Topics_h__

#include <set>
#include <assert.h>
#include "ISubject.h"
#include "Filter.h"
#include "SignalConsts.h"
#include "TimerEvents.h"


namespace Publisher{
namespace Signals{

//Forward declarations...
struct ObservableObjects;
template<typename ArgumentType, typename EventTypes>
class ArgEvents;

//Template friend function definition... Gets the internal container to the event vector in Topics<>
namespace friends
{
	template <typename T> inline
	const typename T::EventContainer& GetEventsContainer(T& subject){
		return subject._eventVec;
	}

	template <typename TE, typename TE_Event> inline
		void InsertEvent(TE& subject, TE_Event event_type, const std::string& echo = ""){
			subject._eventVec.insert(event_type);
	}
}

template<typename ArgumentType, typename EventTypes>
class Topics : public ISubject
{
public:
	typedef std::set<EventTypes> EventContainer;
	typedef ArgEvents<ArgumentType, EventTypes> ArgEvent;
	typedef Observable::SubjectTypes ObserveType;

	//ISubject Implementations
	Observable::SubjectTypes GetType()const{
		return _observableTopic;
	}

	//Copy constructor
	Topics(const Topics& rhs) : 
	_eventVec		(rhs._eventVec),
		_observableTopic(rhs._observableTopic), 
		_pArgEvent		(rhs._pArgEvent ? new ArgumentType(*rhs._pArgEvent): 0),
		_pFilter		(rhs._pFilter ? new Filter(*rhs._pFilter) : 0)
	{}

	//Constructor that takes the argument type for the Publisher subject e.g. Filter object type
	Topics(const ArgumentType& argument_type) :
		_eventVec		((argument_type.p_subject)? (argument_type.p_subject->_eventVec) : EventContainer()), 
		_observableTopic((argument_type.p_subject)? (argument_type.p_subject->_observableTopic) : Observable::ST_Unknown),
		_pArgEvent		(new ArgumentType(argument_type)),
		_pFilter(0)
	{}
	
	//Add events of interest...
	ArgumentType& RegisterForEvents(){
		assert(_pArgEvent);
		return *static_cast<ArgumentType *>(_pArgEvent);
	}

	//Access to the registered events...
	const EventContainer& GetRegisteredEvents()const{
		return _eventVec;
	}

	const Publisher::IMDFilter * GetRegisteredFilter()const{
		return _pFilter;
	}

	Topics& operator=(const ArgumentType& argument_type){
		//assert(argument_type.p_subject);
		if(!argument_type.p_subject)
			return *this;
		_eventVec = argument_type.p_subject->_eventVec; 
		_observableTopic = argument_type.p_subject->_observableTopic;
		if(_pArgEvent)
			delete _pArgEvent;
		_pArgEvent = new ArgumentType(argument_type);
		_pFilter = 0;
		return *this;
	}

	//Virtual Destructor
	virtual ~Topics(){
		delete _pFilter;
		_pFilter = 0;
		delete _pArgEvent;
		_pArgEvent = 0;
	}

private:
	//Constructor that takes the Topic type defined in NotificationConst.h
	Topics(ObserveType obsTopic, const Publisher::Filter * pfilter):
	_observableTopic(obsTopic), 
	_pFilter(pfilter ? new Publisher::Filter(*pfilter): 0),
	_pArgEvent(0)
	{
		_pArgEvent = new ArgumentType(*this);
	}

	Topics(ObserveType obsTopic):
	_observableTopic(obsTopic), 
		_pFilter(0),
		_pArgEvent(0)
	{
		_pArgEvent = new ArgumentType(*this);
	}
	
	//members...
	Filter * _pFilter;  //Here is the first error, This is also the -int assumed errors.
	ArgEvent * _pArgEvent;
	ObserveType _observableTopic;
	EventContainer _eventVec;
	//friends...
	friend struct ObservableObjects;
	template <typename T> 
	friend const typename T::EventContainer& friends::GetEventsContainer(T& subject);
	
	template <typename TE, typename TE_Event>
	friend void friends::InsertEvent(TE& subject, TE_Event event_type, const std::string&);
	
};

	}
}
#endif // Topics_h__ 


 2>d:\Events and Signals\Proj\Ver2.1\h\Topics.h(117): error C2143: syntax error : missing ';' before '*'
2>          d:\Events and Signals\Proj\Ver2.1\h\Topics.h(129) : see reference to class template instantiation 'Publisher::Signals::Topics<ArgumentType,EventTypes>' being compiled
2>d:\Events and Signals\Proj\Ver2.1\h\Topics.h(117): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
2>d:\Events and Signals\Proj\Ver2.1\h\Topics.h(117): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
2>d:\Events and Signals\Proj\Ver2.1\h\Topics.h(117): error C2143: syntax error : missing ';' before '*'
I fixed this by not including Filter.h and using it's base class, changing all pointers to the base and removing allocation for the member. Either you pass in NULL or a valid pointer. I'm not happy about this but I don't have time to make it work the other way. This class shouldn't be exported and neither should the Filter class, however, the base class to Filter is exported.

I'll leave this incase anyone has similar problems.

Also, if anyone has run into this type of scenario and can give me a solution to preserve the use of the Super class in the non exported templated feel free to post. Thanks.
Topic archived. No new replies allowed.