• Welcome to Valhalla Legends Archive.
 

Help with an error please

Started by DarkMinion, December 07, 2005, 10:14 PM

Previous topic - Next topic

DarkMinion

This is the same code I've been using for years, and I just installed VS 2005, and now it's giving me a new error concerning my operators in DynBuffer....here is the code with the problematic lines sandwiched between comments:


#ifndef DYNBUFFER_H_INCLUDED
#define DYNBUFFER_H_INCLUDED
#pragma once

class DynBuffer {
private:
unsigned long dwLen;
unsigned long dwPos;
char *lpszBuffer;
public:
DynBuffer() { lpszBuffer = 0; dwLen = 0; dwPos = 0; }
~DynBuffer() { delete [] lpszBuffer; lpszBuffer = 0; }
void add(const char *lpszData);
void add(const void *lpData, unsigned long dwLength);
void add(unsigned long dwData);
void add(int iData) { add((unsigned long)iData); }
void add(unsigned short uData);
void add(char bData);
void add(unsigned char bData);
void get(void *lpDest, unsigned long dwLength);
void shift(unsigned long dwDest);
void insert(const void *lpData, unsigned long dwPos, unsigned long dwLength);
unsigned long length() { return dwLen; }
void clear();

operator char *(void) { return lpszBuffer + dwPos; }
operator unsigned long(void) { return *(unsigned long *)(lpszBuffer + dwPos); }
operator unsigned short(void) { return *(unsigned short *)(lpszBuffer + dwPos); }
operator char(void) { return lpszBuffer[dwPos]; }

// PROBLEM LINES
operator ++(int) { dwPos++; if(dwPos > dwLen) dwPos = dwLen; }
operator --(int) { dwPos--; if(dwPos < 0) dwPos = 0; }
operator +=(int size) { dwPos += size; if(dwPos > dwLen) dwPos = dwLen; }
operator -=(int size) { dwPos -= size; if(dwPos < 0) dwPos = 0; }
// END PROBLEM LINES
};

#endif


The error I'm getting is:

Quote1>c:\projects\dmbot\DynBuffer.h(31) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

As I've never encountered this problem before and it was working fine with VS.NET 2003, I'm not sure what it's requiring me to do here.

Any ideas?

dxoigmn

Looks like you need return types on those operators.

DarkMinion

Fixed it...odd that it wasn't required in previous versions

dxoigmn

Quote from: DarkMinion on December 08, 2005, 12:02 AM
Fixed it...odd that it wasn't required in previous versions

Probably because it assumed int as the return type. At least, that is what the error suggests.

MyndFyre

You might want to consider returning BOOL or void with those lines.  I suppose you could return int position, or int sizeGained.  It'd be interesting to say

if (buf++) {

}

because the ++ operator would still impact the value of the class and then you could evaluate the return value.  *Shrug* just a thought.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Kp

I prefer having operators return *this if there isn't anything better to return.  Then it's legal to write &++(buf++). :)
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

DarkMinion

I decided to just make them all return dwPos