gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Beginners > using mbv2lib with c++?

#35656 - KonVex - Wed Feb 09, 2005 2:00 am

I wanted to use the mbv2lib for debugging purposes, but if I try to compile a small c++ test program, g++ will abort with a list of errors. What confuses me is that the same program works if treated as c code!
(btw I use devkitARM R8)

The errors:
arm-elf-g++ -c -o output\system_debug.o System_Debug.cpp
System_Debug.cpp: In function `void GBA_Print()':
System_Debug.cpp(9): error: invalid conversion from `unsigned char*' to `char*'
System_Debug.cpp(9): error: initializing argument 1 of `int dsprintf(char*, const char*, ...)'
System_Debug.cpp(9): error: invalid conversion from `unsigned char*' to `char*'
System_Debug.cpp(9): error: initializing argument 1 of `void __PrintStr(char*)'

#35669 - MumblyJoe - Wed Feb 09, 2005 8:11 am

Those errors won't come up with C code because C lets you get away will all sorts of things, while C++ is more type-safe. Basically it appears that at some point you have declared an array (or string if you please) of unsigned chars and thats not what the function wants, it wants signed chars.
_________________
www.hungrydeveloper.com
Version 2.0 now up - guaranteed at least 100% more pleasing!

#35802 - wintermute - Fri Feb 11, 2005 12:48 am

you could always use libgba & the included mbv2 functions :)

http://cvs.sourceforge.net/viewcvs.py/devkitpro/libgba/include/mbv2.h?rev=1.2&view=markup



grab it here - http://sourceforge.net/project/showfiles.php?group_id=114505&package_id=124007&release_id=260441

#35925 - KonVex - Sun Feb 13, 2005 1:37 am

Thanks, I found the problem. :)
The input/output buffers were declared as unsigned char, so I had to change them to chars.
Also I try to minimize the usage of external libs, they tend to add a hefty amount to the ROM size. Hamlib e.g. took almost 64KB and the mbv2lib takes ~6KB.