tags:

views:

49

answers:

2

I'm using Visual Studio 2008 with Feature Pack 1.

I have a typedef like this typedef std::tr1::tuple<std::string, std::string, int> tileInfo with a function like this const tileInfo& GetTile( int x, int y ) const.

In the implementation file the function has the exact same signature (with the added class name qualifier) and I am getting a redefinition: different type modifiers error. It seems to be looking for an int& instead of a tileInfo&

When I mouse over the type of the function in the header, i.e. tileInfo& it brings up a little bar saying static const int tileInfo. I think this may be the problem, but I'm not sure what to do. It leads me to believe that the compiler thinks std::tr1::tuple<std::string, std::string, int> is a static const int.

Any help is appreciated, thanks.

P.S. Here is an example emulating the same situation, just compacted to the minimum.

#include <tuple>

class Blah {
 public:
  typedef std::tr1::tuple<std::string, std::string, int> tileInfo;
  tileInfo& GetTile( int x, int y ); // When you mouse over tileInfo in this line, it says static const int
  ...
};
+2  A: 

Make sure you included header file with the typedef.

It sounds like compiler can't see the typedef so the type of tileInfo defaults to int.

stefanB
It is included. What I described last is actually showing up in the header. The function's signature is below the typedef in public visibility.
Person
do you include `tuple` and `string` before you define typedef?
stefanB
Yes. They are included.
Person
I think it may have something to do with me not installing the Feature Pack 1 correctly or something.
Person
Is the typedef header included within the *header* that declares GetTile? Or just in the source file? If it thinks it's int within the header that leads me to believe it can't figure out what type it is.
Mark B
yes it can't figure out what the type is, we're trying to imagine his code to figure out why ... might be easier if we've see some example code how is it organized ...
stefanB
A: 

It seems that when using the typedef as a return type or a local variable, even within the class, I had to qualify it with the class name as well. For example the GetTile signature in the header should have been TileMap::tileInfo& GetTile( int x, int y ); I thought that you didn't need to do this when the function is in the class with the typedef.

Person