Mantis - GCC-XML
Viewing Issue Advanced Details
6682 major always 2008-03-29 15:46 2009-09-01 09:53
Gustavo J. A. M. Carneiro  
Brad King  
normal  
closed  
fixed  
none    
none  
0006682: Quote vs bracket include behaviour not correct
Trying to parse a project include file everything.h, layout is like this:

everything.h:

#include "string.h"

string.h:

#include <string>

class StringXXX {... };

The test case is attached.

g++ (4.2) compiles this fine, but gccxml gives errors or, in a larger project tree, skips the string.h header altogether.
gccxml errors:

In file included from /usr/include/c++/4.2/cstring:52,
                 from /usr/include/c++/4.2/bits/char_traits.h:45,
                 from /usr/include/c++/4.2/string:47,
                 from string.h:2,
                 from everything.h:2:
string.h:6: error: field 'm_string' has incomplete type
In file included from /usr/include/c++/4.2/bits/char_traits.h:45,
                 from /usr/include/c++/4.2/string:47,
                 from string.h:2,
                 from everything.h:2:
/usr/include/c++/4.2/cstring:80: error: '::memcpy' has not been declared
/usr/include/c++/4.2/cstring:81: error: '::memmove' has not been declared
/usr/include/c++/4.2/cstring:82: error: '::strcpy' has not been declared
/usr/include/c++/4.2/cstring:83: error: '::strncpy' has not been declared
/usr/include/c++/4.2/cstring:84: error: '::strcat' has not been declared
/usr/include/c++/4.2/cstring:85: error: '::strncat' has not been declared
/usr/include/c++/4.2/cstring:86: error: '::memcmp' has not been declared
/usr/include/c++/4.2/cstring:87: error: '::strcmp' has not been declared
/usr/include/c++/4.2/cstring:88: error: '::strcoll' has not been declared
/usr/include/c++/4.2/cstring:89: error: '::strncmp' has not been declared
/usr/include/c++/4.2/cstring:90: error: '::strxfrm' has not been declared
/usr/include/c++/4.2/cstring:91: error: '::strcspn' has not been declared
/usr/include/c++/4.2/cstring:92: error: '::strspn' has not been declared
/usr/include/c++/4.2/cstring:93: error: '::strtok' has not been declared
/usr/include/c++/4.2/cstring:94: error: '::memset' has not been declared
/usr/include/c++/4.2/cstring:95: error: '::strerror' has not been declared
/usr/include/c++/4.2/cstring:96: error: '::strlen' has not been declared
/usr/include/c++/4.2/cstring:98: error: '::memchr' has not been declared
/usr/include/c++/4.2/cstring: In function 'void* std::memchr(void*, int, size_t)':
/usr/include/c++/4.2/cstring:102: error: invalid conversion from 'const void*' to 'void*'
/usr/include/c++/4.2/cstring:102: error: initializing argument 1 of 'void* std::memchr(void*, int, size_t)'
/usr/include/c++/4.2/cstring: At global scope:
/usr/include/c++/4.2/cstring:104: error: '::strchr' has not been declared
/usr/include/c++/4.2/cstring:110: error: '::strpbrk' has not been declared
/usr/include/c++/4.2/cstring:116: error: '::strrchr' has not been declared
/usr/include/c++/4.2/cstring:122: error: '::strstr' has not been declared
In file included from /usr/include/c++/4.2/bits/char_traits.h:46,
                 from /usr/include/c++/4.2/string:47,
                 from string.h:2,
                 from everything.h:2:
/usr/include/c++/4.2/bits/stl_algobase.h: In static member function 'static _Tp* std::__copy<true, std::random_access_iterator_tag>::copy(const _Tp*, const _Tp*, _Tp*)':
/usr/include/c++/4.2/bits/stl_algobase.h:298: error: 'memmove' is not a member of 'std'
/usr/include/c++/4.2/bits/stl_algobase.h: In static member function 'static _Tp* std::__copy_backward<true, std::random_access_iterator_tag>::__copy_b(const _Tp*, const _Tp*, _Tp*)':
/usr/include/c++/4.2/bits/stl_algobase.h:446: error: 'memmove' is not a member of 'std'
/usr/include/c++/4.2/bits/stl_algobase.h: In function 'void std::fill(unsigned char*, unsigned char*, const unsigned char&)':
/usr/include/c++/4.2/bits/stl_algobase.h:600: error: 'memset' is not a member of 'std'
/usr/include/c++/4.2/bits/stl_algobase.h: In function 'void std::fill(signed char*, signed char*, const signed char&)':
/usr/include/c++/4.2/bits/stl_algobase.h:608: error: 'memset' is not a member of 'std'
/usr/include/c++/4.2/bits/stl_algobase.h: In function 'void std::fill(char*, char*, const char&)':
/usr/include/c++/4.2/bits/stl_algobase.h:616: error: 'memset' is not a member of 'std'
/usr/include/c++/4.2/bits/stl_algobase.h: In function 'bool std::lexicographical_compare(const unsigned char*, const unsigned char*, const unsigned char*, const unsigned char*)':
/usr/include/c++/4.2/bits/stl_algobase.h:908: error: 'memcmp' is not a member of 'std'
In file included from /usr/include/c++/4.2/string:47,
                 from string.h:2,
                 from everything.h:2:
/usr/include/c++/4.2/bits/char_traits.h: In static member function 'static typename __gnu_cxx::char_traits<_CharT>::char_type* __gnu_cxx::char_traits<_CharT>::move(_CharT*, const _CharT*, size_t)':
/usr/include/c++/4.2/bits/char_traits.h:186: error: 'memmove' is not a member of 'std'
/usr/include/c++/4.2/bits/char_traits.h: In static member function 'static int std::char_traits<char>::compare(const char*, const char*, size_t)':
/usr/include/c++/4.2/bits/char_traits.h:254: error: 'memcmp' was not declared in this scope
/usr/include/c++/4.2/bits/char_traits.h: In static member function 'static size_t std::char_traits<char>::length(const char*)':
/usr/include/c++/4.2/bits/char_traits.h:258: error: 'strlen' was not declared in this scope
/usr/include/c++/4.2/bits/char_traits.h: In static member function 'static const char* std::char_traits<char>::find(const char*, size_t, const char&)':
/usr/include/c++/4.2/bits/char_traits.h:262: error: invalid conversion from 'const void*' to 'void*'
/usr/include/c++/4.2/bits/char_traits.h:262: error: initializing argument 1 of 'void* std::memchr(void*, int, size_t)'
/usr/include/c++/4.2/bits/char_traits.h: In static member function 'static char* std::char_traits<char>::move(char*, const char*, size_t)':
/usr/include/c++/4.2/bits/char_traits.h:266: error: 'memmove' was not declared in this scope
/usr/include/c++/4.2/bits/char_traits.h: In static member function 'static char* std::char_traits<char>::copy(char*, const char*, size_t)':
/usr/include/c++/4.2/bits/char_traits.h:270: error: 'memcpy' was not declared in this scope
/usr/include/c++/4.2/bits/char_traits.h: In static member function 'static char* std::char_traits<char>::assign(char*, size_t, char)':
/usr/include/c++/4.2/bits/char_traits.h:274: error: 'memset' was not declared in this scope
In file included from /usr/include/c++/4.2/memory:57,
                 from /usr/include/c++/4.2/string:48,
                 from string.h:2,
                 from everything.h:2:
/usr/include/c++/4.2/bits/stl_uninitialized.h: In function 'char* std::uninitialized_copy(const char*, const char*, char*)':
/usr/include/c++/4.2/bits/stl_uninitialized.h:120: error: 'memmove' is not a member of 'std'
/usr/include/c++/4.2/bits/stl_uninitialized.h: In function 'wchar_t* std::uninitialized_copy(const wchar_t*, const wchar_t*, wchar_t*)':
/usr/include/c++/4.2/bits/stl_uninitialized.h:128: error: 'memmove' is not a member of 'std'
In file included from everything.h:2:
string.h: At global scope:
string.h:4: error: redefinition of 'class StringXXX'
string.h:5: error: previous definition of 'class StringXXX'
related to 0009468closed Brad King Quote include behaviour not correct 
zip file icon testcase.zip [^] (734 bytes) 2008-03-29 15:46
Issue History
2008-03-29 15:46 Gustavo J. A. M. Carneiro New Issue
2008-03-29 15:46 Gustavo J. A. M. Carneiro File Added: testcase.zip
2008-03-29 15:48 Gustavo J. A. M. Carneiro Note Added: 0010981
2008-03-30 15:44 Brad King Note Added: 0010983
2009-09-01 09:01 Brad King Relationship added related to 0009468
2009-09-01 09:49 Brad King Status new => assigned
2009-09-01 09:49 Brad King Assigned To => Brad King
2009-09-01 09:53 Brad King Note Added: 0017271
2009-09-01 09:53 Brad King Status assigned => closed
2009-09-01 09:53 Brad King Resolution open => fixed

Notes
(0010981)
Gustavo J. A. M. Carneiro   
2008-03-29 15:48   
PS: This URL explains the differences of #include "xxx" vs <xxx>

http://developer.apple.com/documentation/DeveloperTools/gcc-4.0.1/cpp/Include-Syntax.html [^]
(0010983)
Brad King   
2008-03-30 15:44   
This has nothing to do with quotes versus angle brackets. It's because you have a header "string.h" that duplicates a standard header name. In gccxml the gcc preprocessor is patched to use a "wrapper" include path that overrides standard headers. This allows standard headers from simulated compilers to be copied and patched to parse with the gcc parser. The problem is that this mechanism is conflicting with your header name.

In general I think having project headers that duplicate system header names is a bad idea. Yes, it can be made to work by depending on the "" v. <> style include. However I've seen (cross-) compilers that do not implement it correctly. It is also confusing to others reading the code.

Nevertheless gccxml may be able to be fixed to handle this case. I'm not sure when I can get to it though. For now, if renaming the header is a possibility I suggest doing so to work around this problem.
(0017271)
Brad King   
2009-09-01 09:53   
I've fixed issue 0009468 which is the same as this except that the test case does not use a system header name. There was a subtle interaction problem between a gcc optimization and a gccxml change that was made before the optimization was merged. I think it may fix this problem too. Please re-open if it does not.