+ Reply to Thread
Results 1 to 3 of 3

Thread: c++/cli - irritating compilation error

  1. #1
    jwa
    jwa is offline
    Newbie jwa is an unknown quantity at this point
    Join Date
    Jan 2008
    Posts
    1

    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. #2
    Lop
    Lop is offline
    Speaks fluent binary Lop has a spectacular aura about Lop has a spectacular aura about Lop's Avatar
    Join Date
    May 2006
    Posts
    1,179
    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
    Lop

  3. #3
    Code Warrior dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta's Avatar
    Join Date
    Oct 2007
    Age
    19
    Posts
    2,850
    Blog Entries
    8
    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

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

     

Similar Threads

  1. VB6.0:Tutorial, Error handling
    By TcM in forum VB Tutorials
    Replies: 11
    Last Post: 12-22-2008, 10:03 PM
  2. Compilation Error
    By Victor in forum Java Help
    Replies: 6
    Last Post: 10-05-2007, 08:56 AM
  3. need urgent help finding parce error!!!
    By siren in forum C and C++
    Replies: 3
    Last Post: 09-13-2007, 09:45 AM
  4. Download problem, internal Server Error
    By j3cubcapt in forum ionFiles
    Replies: 1
    Last Post: 07-02-2007, 09:45 AM
  5. can someone help me with my c librarys?
    By bobwrit in forum C and C++
    Replies: 4
    Last Post: 04-27-2007, 06:19 PM

Bookmarks

Bookmarks

     
        Algorithms and Data Structures

        Java tutorials

        Algorithms Forum

Posting Permissions

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