• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Xcode-users Digest, Vol 10, Issue 29
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Xcode-users Digest, Vol 10, Issue 29


  • Subject: Re: Xcode-users Digest, Vol 10, Issue 29
  • From: Feliks Kluzniak <email@hidden>
  • Date: Sat, 26 Jan 2013 19:55:59 +0100

This is a well-known feature of C, apparently inherited by C++.  I quote from Harbison and Steele, C - A Reference Manual, FifthEdition, p. 90:

       "typedef int *int_pointer;
	const int_pointer const_pointer;

	This makes const_pointer look like a "pointer to constant int_pointer", but it is not -- it is still a constant pointer to a (nonconstant) int."

Then they point out that this may be rewritten as

	int_pointer const const_pointer;

If you substitute the type definition you see

	int * const const_pointer;

and light dawns. :-)

Personally, I find that it helps me to avoid the confusion if I always write "const" after the type to which it refers, i.e.,

	int const * p;
	int * const p;

etc.

-- Feliks


On Jan 26, 2013, at 16:47, email@hidden wrote:

> Date: Fri, 25 Jan 2013 20:54:02 -0800
> From: Aaron Montgomery <email@hidden>
> To: Dmitry Markman <email@hidden>
> Cc: "email@hidden list" <email@hidden>
> Subject: Re: clang can not compile simple cpp file with main's second
> 	argument	is typedef
> Message-ID: <email@hidden>
> Content-Type: text/plain; charset=us-ascii
>
>
> On Jan 25, 2013, at 7:37 PM, Dmitry Markman <email@hidden> wrote:
>
>> #include <iostream>
>>
>> typedef char char_T;
>>
>> int main(int argc, const char_T * argv[])
>> {
>>        std::cout << "Hello Test World!" << std::endl;
>>        return 0;
>> }
>
> If you eliminate the const, and pass a char_T**  it compiles (and I think the standard char** not a const char**). What is odd to me is that it will compile if you pass a const char**, but not a const char_T**.
>
> Aaron


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Xcode-users Digest, Vol 10, Issue 29
      • From: Aaron Montgomery <email@hidden>
  • Prev by Date: Re: Will we ever be able to refactor C++?
  • Next by Date: Re: Xcode-users Digest, Vol 10, Issue 29
  • Previous by thread: Re: clang can not compile simple cpp file with main's second argument is typedef
  • Next by thread: Re: Xcode-users Digest, Vol 10, Issue 29
  • Index(es):
    • Date
    • Thread