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.

DS development > Compile bug with string.h in project

#147671 - load*,8,1 - Tue Dec 25, 2007 10:57 pm

I think this might be a bug in the DevKitPro toolchain:
Create an empty file called "string.h" in the "include" folder of a template project. Then #include <cstring>.

These are the error messages I'm getting. I guess that instead of including the string.h of the libraries it is including my own string.h.

Code:
/usr/local/devkitPro/devkitARM/lib/gcc/arm-eabi/4.1.2/../../../../include/c++/4.1.2/cstring:80: error: '::memcpy' has not been declared
/usr/local/devkitPro/devkitARM/lib/gcc/arm-eabi/4.1.2/../../../../include/c++/4.1.2/cstring:81: error: '::memmove' has not been declared
/usr/local/devkitPro/devkitARM/lib/gcc/arm-eabi/4.1.2/../../../../include/c++/4.1.2/cstring:82: error: '::strcpy' has not been declared
/usr/local/devkitPro/devkitARM/lib/gcc/arm-eabi/4.1.2/../../../../include/c++/4.1.2/cstring:83: error: '::strncpy' has not been declared
/usr/local/devkitPro/devkitARM/lib/gcc/arm-eabi/4.1.2/../../../../include/c++/4.1.2/cstring:84: error: '::strcat' has not been declared
/usr/local/devkitPro/devkitARM/lib/gcc/arm-eabi/4.1.2/../../../../include/c++/4.1.2/cstring:85: error: '::strncat' has not been declared
/usr/local/devkitPro/devkitARM/lib/gcc/arm-eabi/4.1.2/../../../../include/c++/4.1.2/cstring:86: error: '::memcmp' has not been declared
/usr/local/devkitPro/devkitARM/lib/gcc/arm-eabi/4.1.2/../../../../include/c++/4.1.2/cstring:87: error: '::strcmp' has not been declared
/usr/local/devkitPro/devkitARM/lib/gcc/arm-eabi/4.1.2/../../../../include/c++/4.1.2/cstring:88: error: '::strcoll' has not been declared
/usr/local/devkitPro/devkitARM/lib/gcc/arm-eabi/4.1.2/../../../../include/c++/4.1.2/cstring:89: error: '::strncmp' has not been declared
/usr/local/devkitPro/devkitARM/lib/gcc/arm-eabi/4.1.2/../../../../include/c++/4.1.2/cstring:90: error: '::strxfrm' has not been declared
/usr/local/devkitPro/devkitARM/lib/gcc/arm-eabi/4.1.2/../../../../include/c++/4.1.2/cstring:91: error: '::strcspn' has not been declared
/usr/local/devkitPro/devkitARM/lib/gcc/arm-eabi/4.1.2/../../../../include/c++/4.1.2/cstring:92: error: '::strspn' has not been declared
/usr/local/devkitPro/devkitARM/lib/gcc/arm-eabi/4.1.2/../../../../include/c++/4.1.2/cstring:93: error: '::strtok' has not been declared
/usr/local/devkitPro/devkitARM/lib/gcc/arm-eabi/4.1.2/../../../../include/c++/4.1.2/cstring:94: error: '::memset' has not been declared
/usr/local/devkitPro/devkitARM/lib/gcc/arm-eabi/4.1.2/../../../../include/c++/4.1.2/cstring:95: error: '::strerror' has not been declared
/usr/local/devkitPro/devkitARM/lib/gcc/arm-eabi/4.1.2/../../../../include/c++/4.1.2/cstring:96: error: '::strlen' has not been declared
/usr/local/devkitPro/devkitARM/lib/gcc/arm-eabi/4.1.2/../../../../include/c++/4.1.2/cstring:98: error: '::memchr' has not been declared
/usr/local/devkitPro/devkitARM/lib/gcc/arm-eabi/4.1.2/../../../../include/c++/4.1.2/cstring: In function 'void* std::memchr(void*, int, size_t)':
/usr/local/devkitPro/devkitARM/lib/gcc/arm-eabi/4.1.2/../../../../include/c++/4.1.2/cstring:102: error: invalid conversion from 'const void*' to 'void*'
/usr/local/devkitPro/devkitARM/lib/gcc/arm-eabi/4.1.2/../../../../include/c++/4.1.2/cstring:102: error:   initializing argument 1 of 'void* std::memchr(void*, int, size_t)'
/usr/local/devkitPro/devkitARM/lib/gcc/arm-eabi/4.1.2/../../../../include/c++/4.1.2/cstring: At global scope:
/usr/local/devkitPro/devkitARM/lib/gcc/arm-eabi/4.1.2/../../../../include/c++/4.1.2/cstring:104: error: '::strchr' has not been declared
/usr/local/devkitPro/devkitARM/lib/gcc/arm-eabi/4.1.2/../../../../include/c++/4.1.2/cstring:110: error: '::strpbrk' has not been declared
/usr/local/devkitPro/devkitARM/lib/gcc/arm-eabi/4.1.2/../../../../include/c++/4.1.2/cstring:116: error: '::strrchr' has not been declared
/usr/local/devkitPro/devkitARM/lib/gcc/arm-eabi/4.1.2/../../../../include/c++/4.1.2/cstring:122: error: '::strstr' has not been declared


I know it's kinda unusual to make a file called like a lib. But that's a filename in the project I'm porting.

#147682 - M3d10n - Wed Dec 26, 2007 2:12 am

load*,8,1 wrote:
I guess that instead of including the string.h of the libraries it is including my own string.h.


This is exactly what is going on. Your string.h is being included instead of the C library one.

AFAIK, you cannot have headers with the same names as the ones from the libraries you're using. I was bitten by this when I decided to call my math header "math.h". Renamed it to "mMath.h" and it was all fine.

Solution: rename your files.

#147696 - Peter - Wed Dec 26, 2007 1:11 pm

M3d10n wrote:
This is exactly what is going on. Your string.h is being included instead of the C library one.

There exist two forms of the #include directive, one quoted form and one with angle brackets which have different behaviour.

Angle-brackets form:
This form is usually used for standard headers, it instructs the preprocessor to search for include files in the directories that are specified using the -I switch.

Quoted form:
Typically used for local includes. The preprocessor looks in the same directory of the file that contains the #include. If the preprocessor cannot find the file, it searches the directories specified by the -I switch.


M3d10n wrote:
AFAIK, you cannot have headers with the same names as the ones from the libraries you're using.

You can, you just have to keep the "" and <> differences in mind.

M3d10n wrote:
Solution: rename your files.

I guess the solution would be to update the makefile. The INCLUDES variable, that contains all the directories which are added to the include directory search path, using the -I switch, also contains local directories which is the troublemaker imo. If you remove "INCLUDES := include" and include string.h using the quoted include form, the error doesn't occur.

PS: but it's usually a good idea not to use standard header names anyway ;)
Personally I create a sub-directory in "project/include" usually with the projectname and store all headers there. So i can use "#include <n3d/math.h>" for example.
_________________
Kind Regards,
Peter