Thom
Thom

Reputation: 15092

undeclared identifier

Need a second set of eyes. I am getting the following error:

1>c:\users\thom\documents\cworkspace\barnaby\barnaby\timezone.h(15): error C2065: 'TransitionTimeInfo' : undeclared identifier

Here is the line of code on which I'm receiving the error:

Timezone(std::vector<LeapSecondsInfo> &leapSecondsVector, std::vector<unsigned char> &localTimeTypes, std::vector<P6::UINT8>  &stdWallIndicators, &std::vector<unsigned long> &transitionTimes, std::vector<TransitionTimeInfo> &transitionTimesInfo, std::vector<P6::UINT8> &utcLocalIndicators){

This is the line for the constructor for my class. This file has the following include:

#include "stdafx.h"

And here is the salient part of the stdafx.h:

#include "targetver.h"
#include "barnaby.h"
#include "LeapSecondsInfo.h"
#include "p6types.h"
#include "Timezone.h"
#include "TransitionTimeInfo.h"

And here is TransitionTimeInfo.h:

class TransitionTimeInfo
{
public:
    TransitionTimeInfo(long gmtOffset, bool daylightSavings, unsigned int abbreviationIndex){
        setAbbreviationIndex(abbreviationIndex);
        setDaylightSavings(daylightSavings);
        setGmtOffset(gmtOffset);
    }
    virtual ~TransitionTimeInfo(void) {};

    unsigned int getAbbreviationIndex(){
        return abbreviationIndex;
    }

    void setAbbreviationIndex(unsigned int newVal){
        abbreviationIndex = newVal;
    }

    bool isDaylightSavings(){
        return daylightSavings;
    }

    void setDaylightSavings(bool newVal){
        daylightSavings = newVal;
    }

    long getGmtOffset(){
        return gmtOffset;
    }

    void setGmtOffset(long newVal){
        gmtOffset = newVal;
    }
private:
    long            gmtOffset;
    bool            daylightSavings;
    unsigned int    abbreviationIndex;
};

What's more, if I click on the type name and hit F12 (Visual C++) it takes me to this file.

Any ideas?

Thanks.

Upvotes: 0

Views: 1284

Answers (1)

Alok Save
Alok Save

Reputation: 206616

Change the order of includes:

#include "TransitionTimeInfo.h"
#include "Timezone.h"

The Timezone.h uses TransitionTimeInfo but the "TransitionTimeInfo.h" is included after it.

Ideally, You should always follow the rule:

Each file should include all the header files it needs and not rely on them getting included indirectly through some other files.

So, You should include "TransitionTimeInfo.h" in "Timezone.h".

Upvotes: 6

Related Questions