Jump to content
  • Advertisement
Sign in to follow this  

error C3861 - identifier not found (header inclusion)

This topic is 2885 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've had this problem for a long time and just can't seem to overcome it, despite reading many tutorials on how to include headers, create them etc.

I have three files. "rts.cpp", "mapgen.h" and "mapgen.cpp"

"mapgen.h" holds declaration for a function that sets my game's map tiles:


int set_tiles();


#include "mapgen.h"

int set_tiles()
tile[0].x = 0;
tile[0].y = 0;
tile[0].h = 96;
tile[0].w = 96;
tile[1].x = 96;
tile[1].y = 0;
tile[1].h = 96;
tile[1].w = 96;
tile[2].x = 192;
tile[2].y = 0;
tile[2].h = 96;
tile[2].w = 96;
tile[3].x = 288;
tile[3].y = 0;
tile[3].h = 96;
tile[3].w = 96;
tile[4].x = 384;
tile[4].y = 0;
tile[4].h = 96;
tile[4].w = 96;

return 0;

my main .cpp file "rts.cpp" has this (related to this function):

#include "stdafx.h"
#include "SDL.h"
#include <stdlib.h>
#include <windows.h>
#include <windowsx.h>
#include <d3d9.h>
#include <d3dx9.h>
#include "SDL_image.h"
#include "SDL_ttf.h"
#include <string>
#include <fstream>
#include <ostream>
#include <sstream>
#include <time.h>
#include "rts.h"
#include "mapgen.h"

SDL_Rect tile[5];

int main( int argc, char* argv[] )

return 0;

I cut away the unrelated code. Anyway calling the function produces this error: 1>c:\users\aske\documents\c++\rts\rts\rts.cpp(116): error C3861: 'set_tiles': identifier not found

I'm using Visual C++ 2010 Express.

I just have no idea why it doesn't recognize the function although it IS declared. I've been struggling with thousands of lines of code in one file for a long time cause I can't solve this. Now it's becoming too much of a problem. :(

E: Oh, and I've had this exact same problem with many variations of this case in different projects and with different functions. Could the problem be with my IDE settings or something?

Share this post

Link to post
Share on other sites
The first thing I would check is if all your headers have unique header guards. If, for example, rts.h had the same header guard identifier as mapgen.h, you could generate this kind of error. If that's not the problem, I'd suggest creating a compete, but minimal, code sample that demonstrates your problem and posting that.

Share this post

Link to post
Share on other sites
Hmm... I seem to have solved the problem. I opened mapgen.h by right clicking it from the #include "mapgen.h" in rts.cpp and noticed it was different from what I had open in another tab (same file in another tab I mean). I changed it to what it was supposed to be.

Then I opened mapgen.cpp from solution explorer only to notice it too was completely different from what I had written in another tab.

So somehow there were two different versions of those files? Anyway now it works... Really weird, but if I can make it work like this, then I am happy enough.

And yes, I had saved and compiled mapgen.h and mapgen.cpp, so it shouldn't be that.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!