error: invalid cast from type _gnu_cxx::__normal_iterator<> to unsigned char*
2017-07-13 13:54
711 查看
在windows VC6编译器上,编译如下代码:
1 typedef unsigned char BYTE;
2 vector<BYTE> pBuffer;
3
4 BYTE RtpHeader[12] ="abcdefg1234";
5 DWORD bufferLen = 160;
6 pBuffer.reserve(bufferLen);
7 pBuffer.assign(bufferLen, 0x00);
8 memcpy(pBuffer.begin(), RtpHeader, 12);
成功,而用g++(gcc) 4.4.7版编译器没有编译成功,提示第8行
8:error: invalid cast from type 鈥榑_gnu_cxx::__normal_iterator<unsignedchar*, std::vector<unsigned char, std::allocator<unsigned char> >>鈥totype BYTE* ,可见g++编译器严格的多,将第8行作如下改动即可编译成功:
8 memcpy(&(*pBuffer.begin()), RtpHeader,12);
1 typedef unsigned char BYTE;
2 vector<BYTE> pBuffer;
3
4 BYTE RtpHeader[12] ="abcdefg1234";
5 DWORD bufferLen = 160;
6 pBuffer.reserve(bufferLen);
7 pBuffer.assign(bufferLen, 0x00);
8 memcpy(pBuffer.begin(), RtpHeader, 12);
成功,而用g++(gcc) 4.4.7版编译器没有编译成功,提示第8行
8:error: invalid cast from type 鈥榑_gnu_cxx::__normal_iterator<unsignedchar*, std::vector<unsigned char, std::allocator<unsigned char> >>鈥totype BYTE* ,可见g++编译器严格的多,将第8行作如下改动即可编译成功:
8 memcpy(&(*pBuffer.begin()), RtpHeader,12);
相关文章推荐
- convert 'std::vector<>::iterator {aka __gnu_cxx::__normal_iterator<*, std::vector<> >}' to '*' in in
- java中的类型安全问题-Type safety: Unchecked cast from Object to ... 或者 Type safety: Unchecked cast from Type to Class<T>
- 关于Unchecked cast from List<String> to Iterator<String>的警告
- convert 'std::vector<>::iterator {aka __gnu_cxx::__normal_iterator<*, std::vector<> >}' to '*' in in
- error: invalid application of 'sizeof' to incomplete type 'QStaticAssertFailure<false>'
- Type safety: Unchecked cast from List to List<Book>
- IOS Assigning to 'id<Delegate>' from incompatible type...解决办法<CALayerDelegate>
- 6410_io_drv.c: error: invalid operands to binary << (have 'char *' and 'int') 错误处理
- IOS Assigning to 'id<UITabBarControllerDelegate>' from incompatible type...
- ios错误<Error>: CGContextSaveGState: invalid context 0x0. If you want to see the backtrace, please set
- error: cast from ‘char*’ to ‘int’ loses precision
- Uncaught TypeError: Object #<HTMLCollection> has no method 'toLowerCase'问题
- Type mismatch: cannot convert from Enumeration<String> to Enumeration<Object>
- error: no matching function for call to ‘ptr_fun(<unresolved overloaded function type>)’
- error: no matching function for call to 'std::basic_ifstream<char>::open(std::string&)
- Assigning to 'AppDelegate *' from incompatible type 'id<UIApplicationDelegate>'
- C++:invalid conversion from 'unsigned char *' to 'const char *'
- Assigning to 'id<UITextViewDelegate>' from incompatible type 'HBComposeViewController *const __stron
- 解决cast from 'char*' to 'char**' increases required alignment of target type [-Werror=cast-align]
- error: cast from ‘char*’ to ‘int’ loses precision