I am getting the following errors when compiling the below code:
3>c:\hedge\hedge\hedge\AisTarget.h(22) : error C2059: syntax error : 'constant'
3>c:\hedge\hedge\hedge\AisTarget.h(22) : error C2238: unexpected token(s) preceding ';'
#if !defined(AisTarget_h)
#define AisTarget_h
#include "GeneralAviationItems.h"
#include <string>
namespace HEDGE {
using namespace GeneralAviation;
class AisTarget : public WaypointLatLon {
public:
static const int NO_DATA = -1000; //here is the error
};
} // end namespace HEDGE
#endif
It is likely that NO_DATA
is already defined as a macro elsewhere, and so it is expanding into something that does not agree with the compiler's notion of a variable name. Try re-naming NO_DATA
to something else.
If there were no such conflict, the code as it were would compile fine, as demonstrated here.
Even if this post has its age: The error can generally occur when multiple redefinitions, even regardless of upper/lower case, coexist. This includes potential preprocessor definitions in the solution's .vcprojx file!. Consider something like
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions>$(Configuration);%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
in the above mentioned file. Now, having "Debug" and "Release" configurations you will most probably run into some problems and a potential source for the C2059 error. I experienced exaclty this dilemma.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With