1

I have my header like:

#include iostream & map
namespace dummy {
    const char* some_xxx_name(const char* name);
}
#include myfile.cpp (the following cpp file stated below)

I have my cpp file like:

#include "myfile.h" (the file stated above)
#include <sstream>
#include <cassert>   
inline const char* dummy::some_xxx_name(const char* name) {
........
}

They are working fine under my linux environment with makefile, now I am adopting in visual studio environment and get following error:

error C2084: function 'const char *dummy::some_xxx_name(const char *)' already has a body ....(point to the line in the header)

I know the file structure is not good at all for including cpp at header and including header at cpp(or maybe).

want to ask if there is any chance to make it work without updating the code? Not familiary how shall I go forward under windows visual studio environment.

Cory Kramer
  • 114,268
  • 16
  • 167
  • 218
thundium
  • 995
  • 4
  • 12
  • 30
  • 1
    Among other problems, you have a circular dependency. – Cory Kramer Nov 13 '14 at 16:24
  • Does your makefile compile the `.cpp` file? Visual Studio compiles all `.cpp` files in project by default. – timrau Nov 13 '14 at 16:25
  • @Cyber I guess it is the header guard that solves the problem. But I admit I find it is strange too. Maybe I need look deep into to see why it was like that. – thundium Nov 13 '14 at 16:35
  • @timrau is that I can change the config so that certain .cpp file (under a directory) won't be compiled? – thundium Nov 13 '14 at 16:37
  • Got this solution http://stackoverflow.com/questions/219381/how-to-exclude-files-from-visual-studio-compile – thundium Nov 13 '14 at 17:20

0 Answers0