OSX TMap define doesn't work - Help!

I’m using OSX XCode 8

in my FBullCowGame.cpp file, at the top, I define:

#define TMap std::map;

But I can’t use in in the function:

bool FBullCowGame::GuessIsIsogramHash(FString Guess) const
{
    // treat 0 & 1 letter words as isograms
    if(Guess.length() < 2)
    {
        return true;
    }

// This line reports a code issue: 
// "Expected '{' for function style case or type construction
TMap<char, bool> LetterSeen;

// But I can write:
std::map<char, bool> LetterSeen2;

Why wouldn’t my #define work?

2 Likes

Did you #include <map> at the top of your file ?

It’s in my header file, and my header file is included at the top.

Just for fun, I tried to move things around, but that’s irrelevant. I included the map, I defined, and looking closer, all the errors are:

"

  1. Semantic Issue Group
    FBullCowGame.cpp:167:5: Use of class template ‘std::map’ requires template arguments
  2. Parse Issue Group
    FBullCowGame.cpp:167:9: Expected expression
    FBullCowGame.cpp:167:14: Expected ‘(’ for function-style cast or type construction"
    "

Besides - I said I could use the code:

std::map<char, bool> LetterSeen2;

but trying to do the same with the #define fails.

Sorry Maybe I should have read more carefully…

Could it be because you are defining TMap with primitive types instead of Unreal Types (char instead of TChar ) ?

No, in the tutorial lesson, they did not as of yet introduce TChar. I typed in exactly as the tutorial had.

@ben I need help! How does this work in OSX XCode 8?

@DevFingers The fact you’re using XCode 8 shouldn’t matter. This is a compiler issue if there is one.

I’ve done this course on Xcode 8 before I tossed my mac in the trash.

But just our of curiosity where is your #include in your header? if so have you tried putting the #define right below it?

This should ensure that the compiler has the definition in memory as it starts running through your .cpp file.

Your problem is the semicolon on the end. This would mean TMap<char,bool> would be replaced with std::map;<char,bool>

3 Likes

OMG - doh! I’ll give that a go… Thanks!

Find the definition of #define somewhere or in the Lecture example and see what the punctuation is. Hint - the #define takes everything after the TMap name as what is substituted for TMap anywhere in the code. It does not use C++ punctuation. It just eats everything until there is no line left (ignoring leading and ending spaces).

If this is not clear, substitute it by hand and see what doesn’t work. Look very closely.

Thanks - I figured it out a couple of weeks ago

@DanM
@ben

Nice catch. I thought that in the video they should have noted the lack of a semi colon at the end of the definition. I just finished this video though so not sure if they mention it in any of the later videos.

1 Like

This thread helped me figure out my problem.

I was writing:

#define TMAP = std::world_map

When I should have left out the “=” and written:

#define TMAP std::map

Thanks everyone in the past discussion for helping me in the future! :wink:

Thank you, I could not figure out this problem, and i had #define TMap = std::map

Privacy & Terms