Closed Thread
Results 1 to 3 of 3

Thread: c++/cli - irritating compilation error

  1. #1
    jwa
    jwa is offline Newbie
    Join Date
    Jan 2008
    Posts
    1
    Rep Power
    0

    c++/cli - irritating compilation error

    After compilation this simple example code, I have irritating error... I don't know what's going on, can anybody help me to solve that?

    File Form1.h
    Code:
    #ifndef __FORM1_H__
    #define __FORM1_H__
    
    #include "TClass.h"
    
    namespace testmycpp
    {
    	public ref class Form1
    	{
    		public:
    			Form1(void);
    		private:
    			TClass ^m_tc;         //this declaracion cause error
    	};
    }
    
    #endif
    File Form1.cpp
    Code:
    #include "stdafx.h"
    #include "Form1.h"
    
    using namespace testmycpp;
    
    Form1::Form1()
    {
    }
    File TClass.h
    Code:
    #ifndef __TCLASS_H__
    #define __TCLASS_H__
    
    namespace testmycpp
    {
    	public ref class TClass
    	{
    		public:
    			TClass(void);
    	};
    }
    
    #endif
    File TClass.cpp
    Code:
    #include "stdafx.h"
    #include "TClass.h"
    
    using namespace testmycpp;
    
    TClass::TClass()
    {
    }
    File stdafx.h
    Code:
    #pragma once
    COMPILER ERROR !!

    Error 1 error C2143: syntax error : missing ';' before '^'
    Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    Error 3 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Lop's Avatar
    Lop
    Lop is offline Speaks fluent binary
    Join Date
    May 2006
    Posts
    1,178
    Rep Power
    30
    I think you are calling that tclass wrong. It should be:

    Code:
    testmycpp::TClass ^m_tc;         //Try this
    That is a strange error. I found this on MSDN: Compiler Error C2143

  4. #3
    Join Date
    Oct 2007
    Location
    /dev/null
    Posts
    4,513
    Blog Entries
    8
    Rep Power
    59
    Whenever you declare a variable of a type that is specified in a namespace such as System or std, you need to put that namespace in front of it like so:

    namespace_name::variable_type

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. compilation error
    By eman ahmed in forum Java Help
    Replies: 5
    Last Post: 09-30-2010, 09:01 AM
  2. GetCurrentTime() compilation error due to Winbase.h
    By harshareddy75 in forum C and C++
    Replies: 3
    Last Post: 06-16-2010, 09:10 PM
  3. Compilation error
    By nagarjuna02 in forum C# Programming
    Replies: 2
    Last Post: 02-08-2010, 05:24 AM
  4. G++ Compilation Error Doesn't Make Sense
    By deltatux in forum C and C++
    Replies: 8
    Last Post: 02-19-2009, 02:17 PM
  5. Compilation Error
    By Victor in forum Java Help
    Replies: 6
    Last Post: 10-05-2007, 06:56 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts