fooOnYou
fooOnYou

Reputation: 698

C++/CLI include problems

doing some C++/CLI coding again, and running into issues. Working in VS2008 if it matters at all.

Here's a mock up of what I am trying to do. In reality ClassA is the GUI and ClassB is the backend that the gui needs to interact with. I am trying to give them access to eachother by passing them to eachother, but I cannot properly get them in scope to create a reference to the other one.

http://pastie.org/private/tnyxazwtyzv3luddz7seq

If you have any input I would greatly appreciate it. I have spent much of today looking online and this solution I currently have has gotten me quite close but I am still getting compile errors. Here's what I am now getting:

Error   1   error C2653: 'NameSpaceB' : is not a class or namespace name    c:\users\andy\documents\visual studio 2008\projects\myhello\myhello\A.h 12  myhello
Error   2   error C2143: syntax error : missing ';' before '^'  c:\users\andy\documents\visual studio 2008\projects\myhello\myhello\A.h 12  myhello
Error   3   error C4430: missing type specifier - int assumed. Note: C++ does not support default-int   c:\users\andy\documents\visual studio 2008\projects\myhello\myhello\A.h 12  myhello
Error   4   error C4430: missing type specifier - int assumed. Note: C++ does not support default-int   c:\users\andy\documents\visual studio 2008\projects\myhello\myhello\A.h 12  myhello
Error   5   error C2653: 'NameSpaceA' : is not a class or namespace name    c:\users\andy\documents\visual studio 2008\projects\myhello\myhello\B.h 12  myhello
Error   6   error C2143: syntax error : missing ';' before '^'  c:\users\andy\documents\visual studio 2008\projects\myhello\myhello\B.h 12  myhello
Error   7   error C4430: missing type specifier - int assumed. Note: C++ does not support default-int   c:\users\andy\documents\visual studio 2008\projects\myhello\myhello\B.h 12  myhello
Error   8   error C4430: missing type specifier - int assumed. Note: C++ does not support default-int   c:\users\andy\documents\visual studio 2008\projects\myhello\myhello\B.h 12  myhello

This is the same error I am getting in my actual project, so I know it's something funky with my configuration.

Upvotes: 2

Views: 869

Answers (1)

Luchian Grigore
Luchian Grigore

Reputation: 258548

/*B.h File Contents*/
#ifndef CLASSB_H
#define CLASSB_H
#include "A.h"

Remove the #include "A.h" part and you're golden. Since class B doesn't use A (at least in the definition), there's no need for the include.

Upvotes: 3

Related Questions