Migration of VC++ 6.0 Project to VC++.NET Compilation Error

G

Guest

I converted my VC++ 6.0 Project to VC++.NET and during compilation, I get the
following error everywhere:

Error 1 error C4430: missing type specifier - int assumed. Note: C++ does
not support default-int g:\argusweb\source\gssutil\xmlmessage.h 20

If is referring to the line:
log_comment(char *psz_comment, long bStart=0);

You can see it in the .h file below:


// XmlMessage.h: interface for the XmlMessage class.
//
//////////////////////////////////////////////////////////////////////

#if
!defined(AFX_XMLMESSAGE_H__9D3221FC_2D98_45A5_A442_FC067DA2064D__INCLUDED_)
#define AFX_XMLMESSAGE_H__9D3221FC_2D98_45A5_A442_FC067DA2064D__INCLUDED_
#define WINVER 0x0502

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "msxml2.h"
#include "gss_types.h"

class XmlMessage
{
public:
static TCHAR* Escape(const TCHAR * pchXML);
log_comment(char *psz_comment, long bStart=0);
CString GetParseError();
static CString FormatDate(CString sDate, CString sDTFormat = _T("%Y/%m/%d
%H:%M:%S"));
XmlMessage(const TCHAR* pchXML, long lSpecial);
XmlMessage();
explicit XmlMessage(const long lGssMsg);
virtual ~XmlMessage();
operator long () {
return m_lGssMsg;
};
operator TCHAR* () {
TCHAR* pch = new TCHAR[m_sXml.GetLength() + 1];
_tcscpy(pch, m_sXml);
return pch;
};
 
B

Brian Muth

Sounds like a valid error message. You need to change to:

int log_comment(char *psz_comment, long bStart=0);

or more likely:

void log_comment(char *psz_comment, long bStart=0);

Brian
 
G

Guest

Thanks. That worked. Needed to set to VOID in front.

Got another questions with compile problem. It does not like this:

friend istream& operator>>(istream& ar, AString& string);

Gives the following error:

Error 2 error C2433: 'ostream' : 'friend' not permitted on data
declarations g:\argusweb\source\dbapp\AString.h 115


Brian Muth said:
Sounds like a valid error message. You need to change to:

int log_comment(char *psz_comment, long bStart=0);

or more likely:

void log_comment(char *psz_comment, long bStart=0);

Brian


Nishal Patel said:
I converted my VC++ 6.0 Project to VC++.NET and during compilation, I get
the
following error everywhere:

Error 1 error C4430: missing type specifier - int assumed. Note: C++ does
not support default-int g:\argusweb\source\gssutil\xmlmessage.h 20

If is referring to the line:
log_comment(char *psz_comment, long bStart=0);

You can see it in the .h file below:


// XmlMessage.h: interface for the XmlMessage class.
//
//////////////////////////////////////////////////////////////////////

#if
!defined(AFX_XMLMESSAGE_H__9D3221FC_2D98_45A5_A442_FC067DA2064D__INCLUDED_)
#define AFX_XMLMESSAGE_H__9D3221FC_2D98_45A5_A442_FC067DA2064D__INCLUDED_
#define WINVER 0x0502

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "msxml2.h"
#include "gss_types.h"

class XmlMessage
{
public:
static TCHAR* Escape(const TCHAR * pchXML);
log_comment(char *psz_comment, long bStart=0);
CString GetParseError();
static CString FormatDate(CString sDate, CString sDTFormat = _T("%Y/%m/%d
%H:%M:%S"));
XmlMessage(const TCHAR* pchXML, long lSpecial);
XmlMessage();
explicit XmlMessage(const long lGssMsg);
virtual ~XmlMessage();
operator long () {
return m_lGssMsg;
};
operator TCHAR* () {
TCHAR* pch = new TCHAR[m_sXml.GetLength() + 1];
_tcscpy(pch, m_sXml);
return pch;
};
 
T

Tamas Demjen

Nishal said:
Thanks. That worked. Needed to set to VOID in front.

Got another questions with compile problem. It does not like this:

friend istream& operator>>(istream& ar, AString& string);

Gives the following error:

Error 2 error C2433: 'ostream' : 'friend' not permitted on data
declarations g:\argusweb\source\dbapp\AString.h 115

The error points to ostream, which I don't see in your code. Where's
AString? You have to show us a short but 100% complete sample that
reproduces the problem, or at least include enough contextual information.

This compiles to me, so it's really not that line of code that causes
the error:

using namespace std;

class AString
{
friend istream& operator>>(istream& ar, AString& string);
};

istream& operator>>(istream& ar, AString& string)
{
return ar;
}

Tom
 
D

Daniel Ford

Yes, that compiles; however, adding

void main()
{
AString a;
cin >> a;
}

gives "error C2593: 'operator >>' is ambiguous."

Though I don't completely understand the cause, one solution appears to be to add prototypes at the beginning, i.e.

class AString;

istream& operator>>(istream& ar, AString& string);

class AString
{
friend istream& operator>>(istream& ar, AString& string);
};


istream& operator>>(istream& ar, AString& string)
{
return ar;
}

void main()
{
AString a;
operator>>(cin, a);
}


However, I don't know if this, in turn, will lead to other problems. If anyone knows of a better, or preferred, solution let me know.
 
Top