Archive: NSIS source error ANSI C++ forbids implicit conversion


NSIS source error ANSI C++ forbids implicit conversion
Hi all helpfull programmers:

Compiling on Solaris SunOS5.8 stumbled accross the following compiler error"

++ -Wall -O3 -DCOMPRESS_MF_BT -c mmap.cpp -o ../Build/mmap.o
mmap.cpp: In method `void MMapFile::release()':
mmap.cpp:300: ANSI C++ forbids implicit conversion from `void *' in argument passing
mmap.cpp: In method `void MMapFile::release(void *, int)':
mmap.cpp:313: ANSI C++ forbids implicit conversion from `void *' in argument passing
mmap.cpp: In method `void MMapFile::flush(int)':
mmap.cpp:323: ANSI C++ forbids implicit conversion from `void *' in argument passing
make: *** [../Build/mmap.o] Error 1

How to fix the source, I'm not (yet) a C++ guro, help appriciated.


Maybe it also depend on what compiler version you're using... :rolleyes:


FYI: I'm using:

gcc version 2.95.3 20010315 (release)
/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/2.95.3/specs

and the code that gives problems
----------------------------------------
void MMapFile::release()
{
if (!m_pView)
return;

#ifdef _WIN32
UnmapViewOfFile(m_pView);
#else
munmap(m_pView, m_iMappedSize);
#endif
m_pView = NULL;
}
----------------------------------------

and I read somwhere:

So it's warning you that ansi c++ won't convert your void* to the required char*. You can cast your stuff variable to a char* instead of a void* to get rid of the warning. I think the key thing to realize is that Solaris shared memory is getting you an array of bytes, while your program is using a structure.
void* is a generic pointer (an address without a type associated with it). They use it in the documentation because they don't know what kind of pointer you'll be using. You can assign any pointer to void*, but you have to cast it when you assign the void* to another pointer.
a void * is a pointer to a memory area. You can treat it as a buffer that is castable to whatever type you'd like. In the linux implementation it's a char *, but a void * is more general.

Anyone can implement this, since C++ on Solaris is not my thing (yet...)


I guess explicit cast doesn't fix it...


Maybe, if you would be so kind as to make the small Cast adjustment as it could be, I'll re-test compile i on Solaris.

Thanks!


I'd try this way and if it works for the error on line 300 then go for it on the other lines as well.


munmap((char *)m_pView, m_iMappedSize);

Yes, great "mmap.o" created (Changed all three lines), THANKS! now I must go on to the next steps, got some other errors...

Will post my progress / problems here.

ElvenProgrammer, you tha man of the day!