Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: CBXE8 - How to turn off warning message in Android compile ?


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 2 - Last Post: Aug 13, 2015 5:55 PM Last Post By: GAI CHEW KAI
GAI CHEW KAI

Posts: 117
Registered: 7/25/14
CBXE8 - How to turn off warning message in Android compile ?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 12, 2015 8:55 PM
Embarcadero® C++Builder XE8 Version 22.0.19027.8951 and Indy 10.
Window 10 Pro x64

QUESTIONS:

1. Is there a way to turn off warning message during android compile such as warning message shown below ?

*[bccaarm Warning] _gen.h(1184): conversion from string literal to 'char ' is deprecate

Please advise.

Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: CBXE8 - How to turn off warning message in Android compile ?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 12, 2015 11:18 PM   in response to: GAI CHEW KAI in response to: GAI CHEW KAI
GAI wrote:

Is there a way to turn off warning message during android compile
such as warning message shown below ?

*[bccaarm Warning] _gen.h(1184): conversion from string literal to
'char ' is deprecate

The real solution is to fix your code. The Clang-based compilers (which
includes Android) implement C++11, and assigning a string literal to a non-const
char* pointer is deprecated by the C++11 standard. You have to use a const
pointer instead (which you should do anyway, since string literals are pointers
to read-only memory):

//char *ptr = "some literal"; // deprecated
const char *ptr = "some literal";

That being said, to answer your question, only the Win32 and OSX compilers
(which do not implement C++11 yet) allow you to enable/disable individual
warnings. For other compilers, it is an all-or-none deal. This is documented
behavior:

C++ Compiler Warnings
http://docwiki.embarcadero.com/RADStudio/XE8/en/C%2B%2B_Compiler_Warnings

Enable selected warnings

Enables only the warning that are set to True. C++ Warning messages are described
in Compiler Errors And Warnings (C++) Index. Default = True

Compiler switches:
bcc32: -w<warning code> See C++ Warnings topic for the warning codes.
bcc64: Platform not supported
bccosx: -w<warning code> See C++ Warnings topic for the warning codes
bcciosarm: Platform not supported
bcciosarm64: Platform not supported
bcciosarm: Platform not supported

This is enforced by the fact that the "Project Options | C++ Compiler | Warnings"
dialog provides checkboxes for individual warnings only for Win32 and OSX
platforms.

However, all is not entirely lost:

Errors and Warnings of Clang-based C++ Compilers
http://docwiki.embarcadero.com/RADStudio/XE8/en/Errors_and_Warnings_of_Clang-based_C%2B%2B_Compilers

Common Warnings Porting from BCC32

Code ported from BCC32 may exhibit some of these warnings (listed alphabetically),
which may be suppressed.

...

Conversion from string literal to 'char *' is deprecated

-Wdeprecated-writable-strings

Assigning a plain char pointer to a literal C-string is discouraged. Make
the pointer const (and if appropriate, consider using std::string).

You could try adding the "-Wno-deprecated-writable-strings" flag to the compiler
options for the Clang-based compilers, either in the Project Options (Project
Options | C++ Compiler | Advanced | Additional options to pass to the compiler)
or in code:

#pragma option push -Wno-deprecated-writable-strings
char *ptr = "some literal"; // deprecated but suppressed warning
#pragma option pop


The Win32 and OSX compilers does not implement C++11 yet, so the deprecation
does not apply to them.

--
Remy Lebeau (TeamB)
GAI CHEW KAI

Posts: 117
Registered: 7/25/14
Re: CBXE8 - How to turn off warning message in Android compile ?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 13, 2015 5:55 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
>....try adding the "-Wno-deprecated-writable-strings...
- Yes, is working now. Thanks again Remy.
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02