So I've been making a program for quite some time, and I've always just worked around this issue because the project wasn't too large, but I've recently been assigned a much larger project, and want to have more files and such. Anyways. Here's the rundown.




#pragma once
#include "stdafx.h"
#include "rsrc.h"
void msg(HWND hWnd)
	MessageBox(hWnd, "Hey!", "It worked!", MB_OK);

msg.cpp is included in the project, but there's no #include "msg.cpp" in main.cpp. It's also just an example file for this thread. That's why it's a stupid function.
If I put #include "msg.cpp" in main.cpp then I get a linking error, "... already defined in main.obj"

error C3861: 'msg': identifier not found

The workaround I always used was just declaring functions as static in stdafx.cpp. That always worked the way I excepted them too... I'm not sure what the problem is here. The problem extends to global variables that I declare in header or other source files... very annoying.

Edited by twentylemon: n/a

8 Years
Discussion Span
Last Post by caut_baia
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.