On 9/10/2009 9:14:42 AM, philipoakley wrote:
>Robert,
>That (the update to the
>mcadincl.h) was just what I
>was looking for. I'll proably
>not go the C++ route just yet,
>but I'm sure that is of help
>to others.
>
>Does the updated ReadOnly tag
>require 'const's on all the
>structure names and pointer
>indirections?
>
>The **hReal pointer vs [i][j]
>indexing also looks fun to
>decypher!
>
>I was expecting that we
>would/should protect all
>except the final returned
>value for returned
>variables...
>
>I also raised this as a coding
>'bug' with PTC tech support.
>
>
>
>Philip Oakley
Philip,
It probably should have const everywhere for consistency, here's a short blog on const
http://blog.voidnish.com/?p=37, but my compiler was flagging M->hReal=0; as an error because I am then trying to modify M which already has the const value defined in LPCCOMPLEXARRAY.
Just to clarify moving to c++, you can vary as much or as little as you want from c. For example, you can use inline functions rather than macros to get type-safe compiler expansion and I personally like the ability to pass by reference whenever possible rather than by pointer because the code is easier to read and I don't have to worry about NULL pointers getting passed around. Going a step further and using c++ for smart pointers allows me to write a class that handles automatic memory cleanup (getting rid of memory leaks) and bounds checking (a real time saver when debugging) without modifying the c syntax for using arrays. Overall, these few modifications give me a big boost in productivity while reducing errors at the same time.
There's a nice little book called "More Effective C++" by Scott Meyers that covers things like smart pointers and why y = x+1; is slower for c++ classes than y=x;y+=1; - the reason being most compilers convert y = x+1; to temp = x; temp+=1;y=temp; I recommend it to people who have some basic working knowledge of c++ as it's fairly easy to read.
Robert