4

I want to use Adafruit_CC3000 arduino library in AVR Studio. I have followed this Instruction to use Adafruit arduino lib with AVR studio so i can use other AVR function too. But I am getting the same error 50 times while i compile the code.

Error 5 reinterpret_cast from type 'const char*' to type '__FlashStringHelper*' casts away qualifiers E:\arduino-1.0.1\libraries\Adafruit_CC3000\Adafruit_CC3000.cpp 183 3 ATmega32_WSClient_CC3K

I have searched on web for such kind of errors. but i failed to understand the issue. I am requesting to make me understand which thing in this code is generatig this error?

Taher Kawantwala
  • 115
  • 2
  • 5
  • 13
  • 1
    You can't use [`reinterpret_cast`](http://en.cppreference.com/w/cpp/language/reinterpret_cast) to cast away the `const` qualifier, only [`const_cast`](http://en.cppreference.com/w/cpp/language/const_cast). – Some programmer dude Jan 26 '15 at 12:00

1 Answers1

15

reinterpret_cast can convert between unrelated pointer types, but can't remove const or volatile qualifiers. You need const_cast for that.

Options are (roughly in order of increasing nastiness):

  • don't use the wrong pointer type in the first place;
  • cast to const __FlashStringHelper*, if you don't need to modify the object;
  • cast from char* if you do need to modify it;
  • use reinterpret_cast<__FlashStringHelper*>(const_cast<char*>(whatever)) or the brute-force (__FlashStringHelper*)whatever if you insist on abandoning the type system entirely.
Mike Seymour
  • 249,747
  • 28
  • 448
  • 644