Click here to Skip to main content
15,881,769 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've a header file
ClientServer.h
C++
// ClientServer.h
#using <mscorlib.dll>
#using "BalanceInquiry.netmodule"
#pragma once
using namespace System;
// This code wraps the C# class using Managed C++
public __gc class BalanceInquiryC
{
public:
    BalanceInquiry __gc *t;
    BalanceInquiryC(){
t=new BalanceInquiry();
    }
};

When I compiled above header file, I got this error:
error C2143: syntax error : missing ';' before 'gc pointer'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C3160: 'int __gc *' : a data member of a managed class cannot have this type
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int


If anyone knows, please help me.
Posted
Updated 12-Jan-11 20:21pm
v3
Comments
Steve Maier 11-Jan-11 22:39pm    
Are you compiling with 2005, 2008, 2010?
N a v a n e e t h 11-Jan-11 23:25pm    
also you don't say compile a header file, header files are included when you compile the relevant source file. If you are using VS2005 or later, I suggest to use the C++/CLI rather than old Managed C++
T2102 11-Jan-11 23:41pm    
If you're writing new code, I might not use C++/CLI in VS2010 is there is no intellisense anymore.

The member BalanceInquiry is regular member of the class, not a constructor. So, where is the type of this member?

Assuming everything before this fragment is correct, it could be:

C++
public:
    BalanceInquiry BalanceInquiry __gc *t;


But, then a public field is bad style; instead it should be a private field exposed by some public property accessor with const... and so on...

Anyway, your immediate bug is spotted.
 
Share this answer
 
Comments
Espen Harlinn 16-Jan-11 17:24pm    
5+ What really tickles me is the comment: "// This code wraps the C# class using Managed C++" - makes me suspect that the whole class is redundant, it may actually by superfluous, or even unneeded :)
Sergey Alexandrovich Kryukov 16-Jan-11 17:40pm    
Right can you be -- Clouded this code is. :-)
Espen Harlinn 16-Jan-11 17:27pm    
BTW: I see you have passed the 10 KP watermark - Gratulations are in order!! (I was sort of expecting to hear from you - have I missed something?)
Sergey Alexandrovich Kryukov 16-Jan-11 17:39pm    
Oh, I see... Thank you. I really don't understand why is there such a jump in the score; it should have happened recently -- have I missed something?
My problem, which was not helped by any of the above comments, was that my c# project i had the class inside a namespace, which presumably changes the way the class would be referenced in C++

My solution was to remove the namespace declaration from my C# project, compile it, and then the compile error was fixed in C++ project
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900