Post Reply 
newRPL: [UPDATED April 27-2017] Firmware for testing available for download
10-09-2016, 02:53 AM (This post was last modified: 10-09-2016 02:54 AM by Sylvain Cote.)
Post: #412
RE: newRPL: [UPDATED September-17-16] Firmware for testing available for download
(10-06-2016 07:27 PM)Claudio L. Wrote:  const char const *string = "Hello";

This allocates a read-only pointer called string (const *), which points to a read-only string (const char).
But the problem is in other platforms (PC and friends) the compilers don't like the double const statements and give warnings.

Claudio,

The reason the compiler give you a warning is because "const char", "char const" and "const char const" are the same thing.
Also, in your hello example, the resulting pointer is not constant.

To really have a constant pointer to a constant data you need to use one of the following ...
const char * const string = "Hello"; // const char means constant data and * const means constant pointer
or
char const * const string = "Hello"; // char const means constant data and * const means constant pointer

Sylvain
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: newRPL: [UPDATED September-17-16] Firmware for testing available for download - Sylvain Cote - 10-09-2016 02:53 AM



User(s) browsing this thread: 16 Guest(s)