<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[VC++ error C2440]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe null Erfahrung ,it VC++ und habe folgendes Problem: Ich möchte eine Application Note von ATMEL benutzen, in em ein Programm enthalten ist, das mit VC++ 6.0 übersetzt wurde und wohl auch lief.</p>
<p>Ich bräuchte ein Idiotensicheres Feedback. Weil meine C-Kenntnisse nutzen mir gar nichts, wenn ich den Code anschaue.</p>
<p>Ich habe die Express Edition 2005 und das SDK installiert. Zum Teil kann ich die Programme der Appl.-Note übersetzen, aber eines bringt Fehlermeldungen. Die tausend Warnungen habe ich mal weggelassen</p>
<p>Vielen Dank vorab.</p>
<blockquote>
<p>1&gt;d:\wolfi\tmp\avr230\source code\create\memorymap.cpp(148) : error C2440: 'Initialisierung': 'std::_Vector_iterator&lt;_Ty,_Alloc&gt;' kann nicht in 'MemoryChunk *' konvertiert werden<br />
1&gt; with<br />
1&gt; [<br />
1&gt; _Ty=MemoryChunk,<br />
1&gt; _Alloc=std::allocator&lt;MemoryChunk&gt;<br />
1&gt; ]<br />
1&gt; Kein benutzerdefinierter Konvertierungsoperator verfügbar, der diese Konvertierung durchführen kann, oder der Operator kann nicht aufgerufen werden<br />
1&gt;d:\wolfi\tmp\avr230\source code\create\memorymap.cpp(148) : error C2679: Binärer Operator '!=': Es konnte kein Operator gefunden werden, der einen rechtsseitigen Operanden vom Typ 'std::_Vector_iterator&lt;_Ty,_Alloc&gt;' akzeptiert (oder keine geeignete Konvertierung möglich)<br />
1&gt; with<br />
1&gt; [<br />
1&gt; _Ty=MemoryChunk,<br />
1&gt; _Alloc=std::allocator&lt;MemoryChunk&gt;<br />
1&gt; ]<br />
1&gt; kann 'eingebauter C++ Operator!=(MemoryChunk *, MemoryChunk *)' sein<br />
1&gt; bei Anpassung der Argumentliste '(MemoryChunk *, std::_Vector_iterator&lt;_Ty,_Alloc&gt;)'<br />
1&gt; with<br />
1&gt; [<br />
1&gt; _Ty=MemoryChunk,<br />
1&gt; _Alloc=std::allocator&lt;MemoryChunk&gt;<br />
1&gt; ]<br />
1&gt;d:\wolfi\tmp\avr230\source code\create\memorymap.cpp(161) : error C2440: 'Initialisierung': 'std::_Vector_iterator&lt;_Ty,_Alloc&gt;' kann nicht in 'MemoryChunk *' konvertiert werden<br />
1&gt; with<br />
1&gt; [<br />
1&gt; _Ty=MemoryChunk,<br />
1&gt; _Alloc=std::allocator&lt;MemoryChunk&gt;<br />
1&gt; ]<br />
1&gt; Kein benutzerdefinierter Konvertierungsoperator verfügbar, der diese Konvertierung durchführen kann, oder der Operator kann nicht aufgerufen werden<br />
1&gt;d:\wolfi\tmp\avr230\source code\create\memorymap.cpp(161) : error C2679: Binärer Operator '!=': Es konnte kein Operator gefunden werden, der einen rechtsseitigen Operanden vom Typ 'std::_Vector_iterator&lt;_Ty,_Alloc&gt;' akzeptiert (oder keine geeignete Konvertierung möglich)<br />
1&gt; with<br />
1&gt; [<br />
1&gt; _Ty=MemoryChunk,<br />
1&gt; _Alloc=std::allocator&lt;MemoryChunk&gt;<br />
1&gt; ]<br />
1&gt; kann 'eingebauter C++ Operator!=(MemoryChunk *, MemoryChunk *)' sein<br />
1&gt; bei Anpassung der Argumentliste '(MemoryChunk *, std::_Vector_iterator&lt;_Ty,_Alloc&gt;)'<br />
1&gt; with<br />
1&gt; [<br />
1&gt; _Ty=MemoryChunk,<br />
1&gt; _Alloc=std::allocator&lt;MemoryChunk&gt;<br />
1&gt; ]<br />
1&gt;OutputWriter.cpp</p>
<p>1&gt;d:\wolfi\tmp\avr230\source code\create\outputwriter.cpp(299) : error C2440: 'Initialisierung': 'std::_String_iterator&lt;_Elem,_Traits,_Alloc&gt;' kann nicht in 'unsigned char *' konvertiert werden<br />
1&gt; with<br />
1&gt; [<br />
1&gt; _Elem=unsigned char,<br />
1&gt; _Traits=std::char_traits&lt;unsigned char&gt;,<br />
1&gt; _Alloc=std::allocator&lt;unsigned char&gt;<br />
1&gt; ]<br />
1&gt; Kein benutzerdefinierter Konvertierungsoperator verfügbar, der diese Konvertierung durchführen kann, oder der Operator kann nicht aufgerufen werden<br />
1&gt;d:\wolfi\tmp\avr230\source code\create\outputwriter.cpp(299) : error C2679: Binärer Operator '!=': Es konnte kein Operator gefunden werden, der einen rechtsseitigen Operanden vom Typ 'std::_String_iterator&lt;_Elem,_Traits,_Alloc&gt;' akzeptiert (oder keine geeignete Konvertierung möglich)<br />
1&gt; with<br />
1&gt; [<br />
1&gt; _Elem=unsigned char,<br />
1&gt; _Traits=std::char_traits&lt;unsigned char&gt;,<br />
1&gt; _Alloc=std::allocator&lt;unsigned char&gt;<br />
1&gt; ]<br />
1&gt; kann 'eingebauter C++ Operator!=(unsigned char *, unsigned char *)' sein<br />
1&gt; bei Anpassung der Argumentliste '(unsigned char *, std::_String_iterator&lt;_Elem,_Traits,_Alloc&gt;)'<br />
1&gt; with<br />
1&gt; [<br />
1&gt; _Elem=unsigned char,<br />
1&gt; _Traits=std::char_traits&lt;unsigned char&gt;,<br />
1&gt; _Alloc=std::allocator&lt;unsigned char&gt;<br />
1&gt; ]</p>
</blockquote>
<p>Ich füge noch die Codestellen ein, die ich für relevant halte (eine Möglichkeit Dateien anzuhängen habe ich nicht gefunden):</p>
<pre><code class="language-cpp">//=============================================================================
// Copyright (C) 2003 Atmel Corporation
//
// File:			MemoryMap.h
// Compiler:		Microsoft Visual C++ 6.0
// Output Size:
// Created:			4-Feb-2003	JP (Atmel Finland)
// Modified:
//
// Support Mail:	avr@atmel.com
//
// Description:		MemoryMap is a list (vector) of MemoryChunks that together
//					constitute the contents of a certain memory, e.g. AVR flash
//					memory contents. It is possible to access the MemoryMap
//					as an array, so the internal structure is that way hidden
//					from the user.
//
// Other Info:		
//=============================================================================

#ifndef MEMORYMAP_H
#define MEMORYMAP_H

#include &quot;MemoryChunk.h&quot;
#include &quot;DataBuffer.h&quot;
#include &lt;vector&gt;

typedef std::vector&lt;MemoryChunk, std::allocator&lt;MemoryChunk&gt; &gt; MemoryChunkVector;

class MemoryMap : private MemoryChunkVector
{
public:
	MemoryMap(unsigned char emptyFill = 0x00);
	MemoryMap(const char *filename, unsigned int start = 0x00000000,
		unsigned int end = 0xffffffff, unsigned char emptyFill = 0x00);

	virtual ~MemoryMap();

	bool in(unsigned int address);
	unsigned char operator [] (unsigned int address);
	unsigned char at(unsigned int address);
	void insert(MemoryChunk&amp; chunk);
	void insert(unsigned int address, const DataBuffer&amp; buffer);
	unsigned int getLowestAddress();
	unsigned int getHighestAddress();

private:
	unsigned char emptyFillM;			// byte that is used as the fill of
										// empty areas in the memory
	unsigned int loLimitM;				// Lowest address containing data
	unsigned int hiLimitM;				// Highest address containing data
};

#endif // MEMORYMAP_H
</code></pre>
<pre><code class="language-cpp">//=============================================================================
// Copyright (C) 2003 Atmel Corporation
//
// File:			MemoryMap.cpp
// Compiler:		Microsoft Visual C++ 6.0
// Output Size:
// Created:			4-Feb-2003	JP (Atmel Finland)
// Modified:
//
// Support Mail:	avr@atmel.com
//
// Description:		MemoryMap is a list (vector) of MemoryChunks that together
//					constitute the contents of a certain memory, e.g. AVR
//					flash memory contents. It is possible to access the
//					MemoryMap as an array, so the internal structure is that
//					way hidden from the user.
//
// Other Info:		
//=============================================================================

#include &quot;MemoryMap.h&quot;
#include &quot;CreateException.h&quot;

//=============================================================================
// Basic constructor

MemoryMap::MemoryMap(unsigned char emptyFill) : loLimitM(0xffffffff),
	hiLimitM(0x00000000), emptyFillM(emptyFill)
{
	// empty
}

//=============================================================================
// Constructor, that reads the contents from an Intel Hex formatted file.

MemoryMap::MemoryMap(const char *filename, unsigned int start,
					 unsigned int end, unsigned char emptyFill)
	: loLimitM(0xffffffff), hiLimitM(0x00000000), emptyFillM(emptyFill)
{
	if (!filename) return;

	FILE *inFile = fopen(filename, &quot;r&quot;);

	if (!inFile)
		throw new CreateException(ERROR_FILE_NOT_FOUND, filename);

	int highAddress = 0;

	while (!feof(inFile))
	{
		char line[300];
		unsigned char length, type;
		int address;

		if (fscanf(inFile, &quot;:%s\n&quot;, line) != 1)
			throw new CreateException(ERROR_HEX_FORMAT, filename);

		// Read the first 5 bytes from the current line of in_file (including
		// the ':') into length, addr and type.
		DataBuffer data(line);

		// Count checksum and make sure that the file is not damaged
		unsigned char chksum = 0;

		for (unsigned int i = 0; i &lt; data.size(); i++)
			chksum += data[i];

		if (chksum != 0)
			throw new CreateException(ERROR_FILE_DAMAGED, filename);

		length = data[0];
		address = (data[1] &lt;&lt; 8) | data[2];
		type = data[3];

		// Remove header and crc from the data
		data = data.substr(4, length);

		switch (type)
		{
			// Data Record (8-, 16-, 32-bit formats)
			case 0:
				try
				{
					insert(address + highAddress, data);
				}

				catch (CreateException *e)
				{
					if (e-&gt;getCode() == ERROR_OVERLAPPING_DATA)
					{
						ErrorCode code = e-&gt;getCode();
						delete e;

						throw new CreateException(code, filename);
					}
					else
						throw e;
				}
				break;

			// End of File Record (8-, 16-, 32-bit formats)
			case 1:
				return;

			// Extended Segment Address Record (16- or 32-bit formats)
			case 2:
				highAddress = (data[0] &lt;&lt; 12) + (data[1] &lt;&lt; 4);
				break;

			// Start Segment Address Record (16- or 32-bit formats)
			case 3:
				break;

			// Extended Linear Address Record (32-bit format)
			case 4:
				highAddress = (data[0] &lt;&lt; 24) + (data[1] &lt;&lt; 16);
				break;

			// Start Linear Address Record (32-bit format)
			case 5:
				break;

			// Unknown type
			default:
				throw new CreateException(ERROR_FILE_DAMAGED, filename);
		}
	}
}

//=============================================================================
// Destructor

MemoryMap::~MemoryMap()
{
	// empty
}

//=============================================================================
// Returns true, if some data resides in the indexed memory location

bool MemoryMap::in(unsigned int address)
{
	for (MemoryChunk *i = begin(); i != end(); i++)
		if (i-&gt;in(address))
			return true;

	return false;
};

//=============================================================================
// Accesses memory by address index

unsigned char MemoryMap::operator [] (unsigned int address)
{
	for (MemoryChunk *i = begin(); i != end(); i++)
		if (i-&gt;in(address))
			return (*i)[address];

	return emptyFillM;
}

//=============================================================================
// Same as 'operator []', except easier to use with pointers to objects
// i.e. in cases like MemoryMap-&gt;at().
// (otherwise user would need to (*MemoryMap)[] which looks clumsy).

unsigned char MemoryMap::at(unsigned int address)
{
	return (*this)[address];
}

//=============================================================================
// Insert a MemoryChunk to MemoryMap

void MemoryMap::insert(MemoryChunk&amp; chunk)
{
	unsigned int address;

	for (address = chunk.getStartAddress();
		address &lt;= chunk.getEndAddress(); address++)
		if (in(address))
			throw new CreateException(ERROR_OVERLAPPING_DATA, &quot;&quot;);

	push_back(chunk);

	if (loLimitM &gt; chunk.getStartAddress())
		loLimitM = chunk.getStartAddress();

	if (hiLimitM &lt; chunk.getEndAddress())
		hiLimitM = chunk.getEndAddress();
}

//=============================================================================
// Insert a DataBuffer (associated with an address) to MemoryMap

void MemoryMap::insert(unsigned int address, const DataBuffer&amp; buffer)
{
	insert(MemoryChunk(address, buffer, emptyFillM));
}

//=============================================================================
// Find the lowest used address in the MemoryMap

unsigned int MemoryMap::getLowestAddress()
{
	return loLimitM;
}

//=============================================================================
// Find the highest used address in the MemoryMap

unsigned int MemoryMap::getHighestAddress()
{
	return hiLimitM;
}
</code></pre>
<pre><code class="language-cpp">//=============================================================================
// Copyright (C) 2003 Atmel Corporation
//
// File:			MemoryChunk.h
// Compiler:		Microsoft Visual C++ 6.0
// Output Size:
// Created:			4-Feb-2003	JP (Atmel Finland)
// Modified:
//
// Support Mail:	avr@atmel.com
//
// Description:		MemoryChunk is inherited from DataBuffer. Additionally,
//					DataBuffer is associated to a memory location using
//					'addressM' member.
//
// Other Info:		
//=============================================================================

#ifndef MEMORYCHUNK_H
#define MEMORYCHUNK_H

#include &quot;DataBuffer.h&quot;

class MemoryChunk : public DataBuffer  
{
public:
	MemoryChunk(int address, const DataBuffer&amp; data, unsigned char emptyFill);
	MemoryChunk(unsigned char emptyFill = 0x00);
	MemoryChunk(const MemoryChunk&amp; chunk);
	virtual ~MemoryChunk();

	MemoryChunk&amp; operator =(const MemoryChunk&amp; rvalue);
	bool in(unsigned int address);
	unsigned char operator[] (int address);

	unsigned int getStartAddress();
	unsigned int getEndAddress();

private:
	unsigned int addressM;
	unsigned char emptyFillM;
};

#endif	// MEMORYCHUNK_H
</code></pre>
<pre><code class="language-cpp">//=============================================================================
// Copyright (C) 2003 Atmel Corporation
//
// File:			MemoryChunk.cpp
// Compiler:		Microsoft Visual C++ 6.0
// Output Size:
// Created:			4-Feb-2003	JP (Atmel Finland)
// Modified:
//
// Support Mail:	avr@atmel.com
//
// Description:		MemoryChunk is inherited from DataBuffer. Additionally,
//					there is an association to a memory location using
//					'addressM' member.
//
// Other Info:		
//=============================================================================

#include &quot;MemoryChunk.h&quot;

//=============================================================================
// Basic constructor

MemoryChunk::MemoryChunk(unsigned char emptyFill) : addressM(0),
	emptyFillM(emptyFill), DataBuffer()
{
	// empty
}

//=============================================================================
// Constructor, that associates a DataBuffer to an address.

MemoryChunk::MemoryChunk(int address, const DataBuffer&amp; data,
	unsigned char emptyFill) : addressM(address), emptyFillM(emptyFill),
	DataBuffer(data)
{
	// empty
}

//=============================================================================
// Copy constructor

MemoryChunk::MemoryChunk(const MemoryChunk&amp; chunk) : DataBuffer(chunk), 
	addressM(chunk.addressM)
{
	// empty
}

//=============================================================================
// Destructor

MemoryChunk::~MemoryChunk()
{
	// empty
}

//=============================================================================
// Assignment, rvalue of type MemoryChunk. Just makes a copy of rvalue.

MemoryChunk&amp; MemoryChunk::operator =(const MemoryChunk&amp; rvalue)
{
	if (this != &amp;rvalue)
	{
		DataBuffer::operator = (rvalue);
		addressM = rvalue.addressM;
		emptyFillM = rvalue.emptyFillM;
	}

	return *this;
}

//=============================================================================
// Returns true, if the address is inside the MemoryChunk area.

bool MemoryChunk::in(unsigned int address)
{
	return (address &gt;= getStartAddress()) &amp;&amp; (address &lt;= getEndAddress());
}

//=============================================================================
// Get a byte from the MemoryChunk, if the address is inside the MemoryChunk.
// If MemoryChunk is 'missed', returns 'emptyFillM'.

unsigned char MemoryChunk::operator [] (int address)
{
	return in(address) ?
		DataBuffer::operator [](address - addressM) : emptyFillM;
}

//=============================================================================
// Returns the start address of the chunk

unsigned int MemoryChunk::getStartAddress()
{
	return addressM;
}

//=============================================================================
// Returns the end address of the chunk

unsigned int MemoryChunk::getEndAddress()
{
	return addressM + size() - 1;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/177378/vc-error-c2440</link><generator>RSS for Node</generator><lastBuildDate>Tue, 21 Apr 2026 15:25:13 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/177378.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 30 Mar 2007 17:09:43 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to VC++ error C2440 on Tue, 03 Apr 2007 06:31:53 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe null Erfahrung ,it VC++ und habe folgendes Problem: Ich möchte eine Application Note von ATMEL benutzen, in em ein Programm enthalten ist, das mit VC++ 6.0 übersetzt wurde und wohl auch lief.</p>
<p>Ich bräuchte ein Idiotensicheres Feedback. Weil meine C-Kenntnisse nutzen mir gar nichts, wenn ich den Code anschaue.</p>
<p>Ich habe die Express Edition 2005 und das SDK installiert. Zum Teil kann ich die Programme der Appl.-Note übersetzen, aber eines bringt Fehlermeldungen. Die tausend Warnungen habe ich mal weggelassen</p>
<p>Vielen Dank vorab.</p>
<blockquote>
<p>1&gt;d:\wolfi\tmp\avr230\source code\create\memorymap.cpp(148) : error C2440: 'Initialisierung': 'std::_Vector_iterator&lt;_Ty,_Alloc&gt;' kann nicht in 'MemoryChunk *' konvertiert werden<br />
1&gt; with<br />
1&gt; [<br />
1&gt; _Ty=MemoryChunk,<br />
1&gt; _Alloc=std::allocator&lt;MemoryChunk&gt;<br />
1&gt; ]<br />
1&gt; Kein benutzerdefinierter Konvertierungsoperator verfügbar, der diese Konvertierung durchführen kann, oder der Operator kann nicht aufgerufen werden<br />
1&gt;d:\wolfi\tmp\avr230\source code\create\memorymap.cpp(148) : error C2679: Binärer Operator '!=': Es konnte kein Operator gefunden werden, der einen rechtsseitigen Operanden vom Typ 'std::_Vector_iterator&lt;_Ty,_Alloc&gt;' akzeptiert (oder keine geeignete Konvertierung möglich)<br />
1&gt; with<br />
1&gt; [<br />
1&gt; _Ty=MemoryChunk,<br />
1&gt; _Alloc=std::allocator&lt;MemoryChunk&gt;<br />
1&gt; ]<br />
1&gt; kann 'eingebauter C++ Operator!=(MemoryChunk *, MemoryChunk *)' sein<br />
1&gt; bei Anpassung der Argumentliste '(MemoryChunk *, std::_Vector_iterator&lt;_Ty,_Alloc&gt;)'<br />
1&gt; with<br />
1&gt; [<br />
1&gt; _Ty=MemoryChunk,<br />
1&gt; _Alloc=std::allocator&lt;MemoryChunk&gt;<br />
1&gt; ]<br />
1&gt;d:\wolfi\tmp\avr230\source code\create\memorymap.cpp(161) : error C2440: 'Initialisierung': 'std::_Vector_iterator&lt;_Ty,_Alloc&gt;' kann nicht in 'MemoryChunk *' konvertiert werden<br />
1&gt; with<br />
1&gt; [<br />
1&gt; _Ty=MemoryChunk,<br />
1&gt; _Alloc=std::allocator&lt;MemoryChunk&gt;<br />
1&gt; ]<br />
1&gt; Kein benutzerdefinierter Konvertierungsoperator verfügbar, der diese Konvertierung durchführen kann, oder der Operator kann nicht aufgerufen werden<br />
1&gt;d:\wolfi\tmp\avr230\source code\create\memorymap.cpp(161) : error C2679: Binärer Operator '!=': Es konnte kein Operator gefunden werden, der einen rechtsseitigen Operanden vom Typ 'std::_Vector_iterator&lt;_Ty,_Alloc&gt;' akzeptiert (oder keine geeignete Konvertierung möglich)<br />
1&gt; with<br />
1&gt; [<br />
1&gt; _Ty=MemoryChunk,<br />
1&gt; _Alloc=std::allocator&lt;MemoryChunk&gt;<br />
1&gt; ]<br />
1&gt; kann 'eingebauter C++ Operator!=(MemoryChunk *, MemoryChunk *)' sein<br />
1&gt; bei Anpassung der Argumentliste '(MemoryChunk *, std::_Vector_iterator&lt;_Ty,_Alloc&gt;)'<br />
1&gt; with<br />
1&gt; [<br />
1&gt; _Ty=MemoryChunk,<br />
1&gt; _Alloc=std::allocator&lt;MemoryChunk&gt;<br />
1&gt; ]<br />
1&gt;OutputWriter.cpp</p>
<p>1&gt;d:\wolfi\tmp\avr230\source code\create\outputwriter.cpp(299) : error C2440: 'Initialisierung': 'std::_String_iterator&lt;_Elem,_Traits,_Alloc&gt;' kann nicht in 'unsigned char *' konvertiert werden<br />
1&gt; with<br />
1&gt; [<br />
1&gt; _Elem=unsigned char,<br />
1&gt; _Traits=std::char_traits&lt;unsigned char&gt;,<br />
1&gt; _Alloc=std::allocator&lt;unsigned char&gt;<br />
1&gt; ]<br />
1&gt; Kein benutzerdefinierter Konvertierungsoperator verfügbar, der diese Konvertierung durchführen kann, oder der Operator kann nicht aufgerufen werden<br />
1&gt;d:\wolfi\tmp\avr230\source code\create\outputwriter.cpp(299) : error C2679: Binärer Operator '!=': Es konnte kein Operator gefunden werden, der einen rechtsseitigen Operanden vom Typ 'std::_String_iterator&lt;_Elem,_Traits,_Alloc&gt;' akzeptiert (oder keine geeignete Konvertierung möglich)<br />
1&gt; with<br />
1&gt; [<br />
1&gt; _Elem=unsigned char,<br />
1&gt; _Traits=std::char_traits&lt;unsigned char&gt;,<br />
1&gt; _Alloc=std::allocator&lt;unsigned char&gt;<br />
1&gt; ]<br />
1&gt; kann 'eingebauter C++ Operator!=(unsigned char *, unsigned char *)' sein<br />
1&gt; bei Anpassung der Argumentliste '(unsigned char *, std::_String_iterator&lt;_Elem,_Traits,_Alloc&gt;)'<br />
1&gt; with<br />
1&gt; [<br />
1&gt; _Elem=unsigned char,<br />
1&gt; _Traits=std::char_traits&lt;unsigned char&gt;,<br />
1&gt; _Alloc=std::allocator&lt;unsigned char&gt;<br />
1&gt; ]</p>
</blockquote>
<p>Ich füge noch die Codestellen ein, die ich für relevant halte (eine Möglichkeit Dateien anzuhängen habe ich nicht gefunden):</p>
<pre><code class="language-cpp">//=============================================================================
// Copyright (C) 2003 Atmel Corporation
//
// File:			MemoryMap.h
// Compiler:		Microsoft Visual C++ 6.0
// Output Size:
// Created:			4-Feb-2003	JP (Atmel Finland)
// Modified:
//
// Support Mail:	avr@atmel.com
//
// Description:		MemoryMap is a list (vector) of MemoryChunks that together
//					constitute the contents of a certain memory, e.g. AVR flash
//					memory contents. It is possible to access the MemoryMap
//					as an array, so the internal structure is that way hidden
//					from the user.
//
// Other Info:		
//=============================================================================

#ifndef MEMORYMAP_H
#define MEMORYMAP_H

#include &quot;MemoryChunk.h&quot;
#include &quot;DataBuffer.h&quot;
#include &lt;vector&gt;

typedef std::vector&lt;MemoryChunk, std::allocator&lt;MemoryChunk&gt; &gt; MemoryChunkVector;

class MemoryMap : private MemoryChunkVector
{
public:
	MemoryMap(unsigned char emptyFill = 0x00);
	MemoryMap(const char *filename, unsigned int start = 0x00000000,
		unsigned int end = 0xffffffff, unsigned char emptyFill = 0x00);

	virtual ~MemoryMap();

	bool in(unsigned int address);
	unsigned char operator [] (unsigned int address);
	unsigned char at(unsigned int address);
	void insert(MemoryChunk&amp; chunk);
	void insert(unsigned int address, const DataBuffer&amp; buffer);
	unsigned int getLowestAddress();
	unsigned int getHighestAddress();

private:
	unsigned char emptyFillM;			// byte that is used as the fill of
										// empty areas in the memory
	unsigned int loLimitM;				// Lowest address containing data
	unsigned int hiLimitM;				// Highest address containing data
};

#endif // MEMORYMAP_H
</code></pre>
<pre><code class="language-cpp">//=============================================================================
// Copyright (C) 2003 Atmel Corporation
//
// File:			MemoryMap.cpp
// Compiler:		Microsoft Visual C++ 6.0
// Output Size:
// Created:			4-Feb-2003	JP (Atmel Finland)
// Modified:
//
// Support Mail:	avr@atmel.com
//
// Description:		MemoryMap is a list (vector) of MemoryChunks that together
//					constitute the contents of a certain memory, e.g. AVR
//					flash memory contents. It is possible to access the
//					MemoryMap as an array, so the internal structure is that
//					way hidden from the user.
//
// Other Info:		
//=============================================================================

#include &quot;MemoryMap.h&quot;
#include &quot;CreateException.h&quot;

//=============================================================================
// Basic constructor

MemoryMap::MemoryMap(unsigned char emptyFill) : loLimitM(0xffffffff),
	hiLimitM(0x00000000), emptyFillM(emptyFill)
{
	// empty
}

//=============================================================================
// Constructor, that reads the contents from an Intel Hex formatted file.

MemoryMap::MemoryMap(const char *filename, unsigned int start,
					 unsigned int end, unsigned char emptyFill)
	: loLimitM(0xffffffff), hiLimitM(0x00000000), emptyFillM(emptyFill)
{
	if (!filename) return;

	FILE *inFile = fopen(filename, &quot;r&quot;);

	if (!inFile)
		throw new CreateException(ERROR_FILE_NOT_FOUND, filename);

	int highAddress = 0;

	while (!feof(inFile))
	{
		char line[300];
		unsigned char length, type;
		int address;

		if (fscanf(inFile, &quot;:%s\n&quot;, line) != 1)
			throw new CreateException(ERROR_HEX_FORMAT, filename);

		// Read the first 5 bytes from the current line of in_file (including
		// the ':') into length, addr and type.
		DataBuffer data(line);

		// Count checksum and make sure that the file is not damaged
		unsigned char chksum = 0;

		for (unsigned int i = 0; i &lt; data.size(); i++)
			chksum += data[i];

		if (chksum != 0)
			throw new CreateException(ERROR_FILE_DAMAGED, filename);

		length = data[0];
		address = (data[1] &lt;&lt; 8) | data[2];
		type = data[3];

		// Remove header and crc from the data
		data = data.substr(4, length);

		switch (type)
		{
			// Data Record (8-, 16-, 32-bit formats)
			case 0:
				try
				{
					insert(address + highAddress, data);
				}

				catch (CreateException *e)
				{
					if (e-&gt;getCode() == ERROR_OVERLAPPING_DATA)
					{
						ErrorCode code = e-&gt;getCode();
						delete e;

						throw new CreateException(code, filename);
					}
					else
						throw e;
				}
				break;

			// End of File Record (8-, 16-, 32-bit formats)
			case 1:
				return;

			// Extended Segment Address Record (16- or 32-bit formats)
			case 2:
				highAddress = (data[0] &lt;&lt; 12) + (data[1] &lt;&lt; 4);
				break;

			// Start Segment Address Record (16- or 32-bit formats)
			case 3:
				break;

			// Extended Linear Address Record (32-bit format)
			case 4:
				highAddress = (data[0] &lt;&lt; 24) + (data[1] &lt;&lt; 16);
				break;

			// Start Linear Address Record (32-bit format)
			case 5:
				break;

			// Unknown type
			default:
				throw new CreateException(ERROR_FILE_DAMAGED, filename);
		}
	}
}

//=============================================================================
// Destructor

MemoryMap::~MemoryMap()
{
	// empty
}

//=============================================================================
// Returns true, if some data resides in the indexed memory location

bool MemoryMap::in(unsigned int address)
{
	for (MemoryChunk *i = begin(); i != end(); i++)
		if (i-&gt;in(address))
			return true;

	return false;
};

//=============================================================================
// Accesses memory by address index

unsigned char MemoryMap::operator [] (unsigned int address)
{
	for (MemoryChunk *i = begin(); i != end(); i++)
		if (i-&gt;in(address))
			return (*i)[address];

	return emptyFillM;
}

//=============================================================================
// Same as 'operator []', except easier to use with pointers to objects
// i.e. in cases like MemoryMap-&gt;at().
// (otherwise user would need to (*MemoryMap)[] which looks clumsy).

unsigned char MemoryMap::at(unsigned int address)
{
	return (*this)[address];
}

//=============================================================================
// Insert a MemoryChunk to MemoryMap

void MemoryMap::insert(MemoryChunk&amp; chunk)
{
	unsigned int address;

	for (address = chunk.getStartAddress();
		address &lt;= chunk.getEndAddress(); address++)
		if (in(address))
			throw new CreateException(ERROR_OVERLAPPING_DATA, &quot;&quot;);

	push_back(chunk);

	if (loLimitM &gt; chunk.getStartAddress())
		loLimitM = chunk.getStartAddress();

	if (hiLimitM &lt; chunk.getEndAddress())
		hiLimitM = chunk.getEndAddress();
}

//=============================================================================
// Insert a DataBuffer (associated with an address) to MemoryMap

void MemoryMap::insert(unsigned int address, const DataBuffer&amp; buffer)
{
	insert(MemoryChunk(address, buffer, emptyFillM));
}

//=============================================================================
// Find the lowest used address in the MemoryMap

unsigned int MemoryMap::getLowestAddress()
{
	return loLimitM;
}

//=============================================================================
// Find the highest used address in the MemoryMap

unsigned int MemoryMap::getHighestAddress()
{
	return hiLimitM;
}
</code></pre>
<pre><code class="language-cpp">//=============================================================================
// Copyright (C) 2003 Atmel Corporation
//
// File:			MemoryChunk.h
// Compiler:		Microsoft Visual C++ 6.0
// Output Size:
// Created:			4-Feb-2003	JP (Atmel Finland)
// Modified:
//
// Support Mail:	avr@atmel.com
//
// Description:		MemoryChunk is inherited from DataBuffer. Additionally,
//					DataBuffer is associated to a memory location using
//					'addressM' member.
//
// Other Info:		
//=============================================================================

#ifndef MEMORYCHUNK_H
#define MEMORYCHUNK_H

#include &quot;DataBuffer.h&quot;

class MemoryChunk : public DataBuffer  
{
public:
	MemoryChunk(int address, const DataBuffer&amp; data, unsigned char emptyFill);
	MemoryChunk(unsigned char emptyFill = 0x00);
	MemoryChunk(const MemoryChunk&amp; chunk);
	virtual ~MemoryChunk();

	MemoryChunk&amp; operator =(const MemoryChunk&amp; rvalue);
	bool in(unsigned int address);
	unsigned char operator[] (int address);

	unsigned int getStartAddress();
	unsigned int getEndAddress();

private:
	unsigned int addressM;
	unsigned char emptyFillM;
};

#endif	// MEMORYCHUNK_H
</code></pre>
<pre><code class="language-cpp">//=============================================================================
// Copyright (C) 2003 Atmel Corporation
//
// File:			MemoryChunk.cpp
// Compiler:		Microsoft Visual C++ 6.0
// Output Size:
// Created:			4-Feb-2003	JP (Atmel Finland)
// Modified:
//
// Support Mail:	avr@atmel.com
//
// Description:		MemoryChunk is inherited from DataBuffer. Additionally,
//					there is an association to a memory location using
//					'addressM' member.
//
// Other Info:		
//=============================================================================

#include &quot;MemoryChunk.h&quot;

//=============================================================================
// Basic constructor

MemoryChunk::MemoryChunk(unsigned char emptyFill) : addressM(0),
	emptyFillM(emptyFill), DataBuffer()
{
	// empty
}

//=============================================================================
// Constructor, that associates a DataBuffer to an address.

MemoryChunk::MemoryChunk(int address, const DataBuffer&amp; data,
	unsigned char emptyFill) : addressM(address), emptyFillM(emptyFill),
	DataBuffer(data)
{
	// empty
}

//=============================================================================
// Copy constructor

MemoryChunk::MemoryChunk(const MemoryChunk&amp; chunk) : DataBuffer(chunk), 
	addressM(chunk.addressM)
{
	// empty
}

//=============================================================================
// Destructor

MemoryChunk::~MemoryChunk()
{
	// empty
}

//=============================================================================
// Assignment, rvalue of type MemoryChunk. Just makes a copy of rvalue.

MemoryChunk&amp; MemoryChunk::operator =(const MemoryChunk&amp; rvalue)
{
	if (this != &amp;rvalue)
	{
		DataBuffer::operator = (rvalue);
		addressM = rvalue.addressM;
		emptyFillM = rvalue.emptyFillM;
	}

	return *this;
}

//=============================================================================
// Returns true, if the address is inside the MemoryChunk area.

bool MemoryChunk::in(unsigned int address)
{
	return (address &gt;= getStartAddress()) &amp;&amp; (address &lt;= getEndAddress());
}

//=============================================================================
// Get a byte from the MemoryChunk, if the address is inside the MemoryChunk.
// If MemoryChunk is 'missed', returns 'emptyFillM'.

unsigned char MemoryChunk::operator [] (int address)
{
	return in(address) ?
		DataBuffer::operator [](address - addressM) : emptyFillM;
}

//=============================================================================
// Returns the start address of the chunk

unsigned int MemoryChunk::getStartAddress()
{
	return addressM;
}

//=============================================================================
// Returns the end address of the chunk

unsigned int MemoryChunk::getEndAddress()
{
	return addressM + size() - 1;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1256192</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1256192</guid><dc:creator><![CDATA[Wolfgang Weinmann]]></dc:creator><pubDate>Tue, 03 Apr 2007 06:31:53 GMT</pubDate></item><item><title><![CDATA[Reply to VC++ error C2440 on Fri, 30 Mar 2007 20:02:44 GMT]]></title><description><![CDATA[<p>@Mods: Copyright Geschützter Source-Code abzudrucken scheint mir illegal...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1256282</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1256282</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Fri, 30 Mar 2007 20:02:44 GMT</pubDate></item><item><title><![CDATA[Reply to VC++ error C2440 on Fri, 30 Mar 2007 20:25:36 GMT]]></title><description><![CDATA[<p>Jochen Kalmbach schrieb:</p>
<blockquote>
<p>@Mods: Copyright Geschützter Source-Code abzudrucken scheint mir illegal...</p>
</blockquote>
<p>Der Code kann von jedem bei Atmel heruntergeladen werden. Insofern ist das sicher erlaubt zu zeigen.</p>
<p>Wolfgang</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1256298</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1256298</guid><dc:creator><![CDATA[Wolfgang Weinmann]]></dc:creator><pubDate>Fri, 30 Mar 2007 20:25:36 GMT</pubDate></item><item><title><![CDATA[Reply to VC++ error C2440 on Sat, 31 Mar 2007 12:48:39 GMT]]></title><description><![CDATA[<p>Wolfgang Weinmann schrieb:</p>
<blockquote>
<p>Der Code kann von jedem bei Atmel heruntergeladen werden. Insofern ist das sicher erlaubt zu zeigen.</p>
<p>Wolfgang</p>
</blockquote>
<p>Aber selbst wenn, wird sich hier niemand die Mühe machen, sich 448 Zeilen (ja, ich hab' nachgezählt :D) unformatierten Code anzusehen auf der Suche nach einem möglichen Fehler. Frag doch lieber die Mitarbeiter von Atmel, ob die eine VC2005-taugliche Version davon haben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1256567</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1256567</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Sat, 31 Mar 2007 12:48:39 GMT</pubDate></item><item><title><![CDATA[Reply to VC++ error C2440 on Sat, 31 Mar 2007 13:55:17 GMT]]></title><description><![CDATA[<p>CStoll schrieb:</p>
<blockquote>
<p>Aber selbst wenn, wird sich hier niemand die Mühe machen, sich 448 Zeilen (ja, ich hab' nachgezählt :D) unformatierten Code anzusehen auf der Suche nach einem möglichen Fehler. Frag doch lieber die Mitarbeiter von Atmel, ob die eine VC2005-taugliche Version davon haben.</p>
</blockquote>
<p>Das habe ich versucht. Die Antwort war, daß das Programm mit der Version 6.0 übersetzt worden ist und daß eine übersetzte Variante dabei sei.<br />
Das nutzt mir aber nichts, da ich für meine Anwendung eine Kleinigkeit abändern muß.</p>
<p>Den Aufwand für einen C++ Experten habe ich als gering vermutet. Die Fehlermeldungen habe ich ja mit eingefügt. Man muß ja nicht einen komplizierten Algorithmus durcharbeiten - es geht ja um eine Typinkompatibilität.</p>
<p>Wolfgang</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1256594</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1256594</guid><dc:creator><![CDATA[Wolfgang Weinmann]]></dc:creator><pubDate>Sat, 31 Mar 2007 13:55:17 GMT</pubDate></item><item><title><![CDATA[Reply to VC++ error C2440 on Tue, 03 Apr 2007 06:41:10 GMT]]></title><description><![CDATA[<p>Da wäre es wenigstens hilfreich gewesen, wirklich nur die relevanten Teile des Programms hierher zu stellen - und das Syntax-Highlighting des Boards zu nutzen.</p>
<p>Zu deinem Problem: vector&lt;&gt;::iterator <em>kann</em> als simpler Pointer implementiert sein, aber der Standard garantiert das nicht. Und allen Anschein nach nutzt das Prgramm die Eigenheit aus, daß VC6 es so gelöst hat. Der standardkonforme Weg wäre es, die <code>MemoryChunk* i</code> s zu ersetzen durch <code>MemoryChunkVector::iterator i</code> (oder kürzer <code>iterator i</code> ).</p>
<p>(was für Probleme die &quot;OutputWriter.cpp&quot; hat, kann ich nicht beurteilen, aber vermutlich läuft es auf das selbe hinaus - verwende <code>string::iterator</code> anstelle von <code>char*</code> )</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1258311</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1258311</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Tue, 03 Apr 2007 06:41:10 GMT</pubDate></item><item><title><![CDATA[Reply to VC++ error C2440 on Tue, 03 Apr 2007 18:44:29 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>tausend Dank - genau das war es. Das mit dem Formatieren habe ich auf die Schnelle nach bestem Wissen und Gewisssen gemacht - sorry, wenn es nicht so übersichtlich war.</p>
<p>Noch eine kurze abschließende Frage: was hat es mit dem iterator auf sich - ist das eine Art Typecast oder wie kann man das verstehen. In der Hilfe kommen zu Iterator gleich x Einträge, die ich kaum verstehe.</p>
<p>Gruß</p>
<p>Wolfgang</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1258789</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1258789</guid><dc:creator><![CDATA[Wolfgang Weinmann]]></dc:creator><pubDate>Tue, 03 Apr 2007 18:44:29 GMT</pubDate></item><item><title><![CDATA[Reply to VC++ error C2440 on Wed, 04 Apr 2007 06:22:41 GMT]]></title><description><![CDATA[<p>In Kurzfassung: Die STL hat ein ca. halbes Dutzend (*nachzählt* genau gesagt sieben) verschiedene Containerklassen, die sich jeweils etwas unterschiedlich verhalten können, und eine große Sammlung an <a href="http://cppreference.com/cppalgorithm/index.html" rel="nofollow">Algorithmen</a>, die mit Datensequenzen umgehen können. Um beides zusammenfügen zu können, gibt es Iteratoren - spezielle zeiger-ähnliche Klassen, die wissen, wie sie durch IHREN Container durchlaufen können.</p>
<p>(wenn du es ausführlicher haben willst, lies mal meine Artikelserie &quot;Aufbau der STL&quot; im Magazin)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1258928</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1258928</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Wed, 04 Apr 2007 06:22:41 GMT</pubDate></item></channel></rss>