Re: const oddity in decorated names
On Wed, 21 Feb 2007 13:21:08 -0800, J Levin
<JLevin@discussions.microsoft.com> wrote:
I will test dllimport at work tomorrow.
The reason I'm chasing this at all is that the extra const not only appears
in the decorated name, but it also shows up in various error messages. I made
the classic mistake to try to cast Foo** -> const Foo** (actually LPCTSTR[]
-> TCHAR**) as described in
http://www.new-brunswick.net/workshop/c++/faq/const-correctness.html#faq-18.17 . Then I got confused by the extra const that showed up in the error message.
That is a classic. Now that you mention it, I have noticed the top-level
const in error messages, but I just read over it.
But considering how slow the VC team's response has been to the much more
severe auto_ptr bug in VS2005 I don't think there is much use reporting this
cosmetic bug. (The auto_ptr bug will not be fixed for VS2005 only for orca.
http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=101842 )
Thanks for all the feedback! Even for an issue that only of academic interest.
You're welcome. The best thing is to use pointer syntax rather than array
syntax for the first dimension of "array" parameters in function parameter
declarations. (I quoted "array" because a function parameter cannot be an
array, but only a pointer, or in C++, a reference to an array.) In the
beginning, allowing array syntax was intended to ease declaring these
parameters by making declaration mimic usage, but mainly, it's confused
people from Day 1. Pointers and arrays are very different, and this is the
only place in the language where [], [10], and [100] mean the same thing as
*.
--
Doug Harrison
Visual C++ MVP