News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

How to detect and auto change to ->

Started by ocdmonkey, January 29, 2015, 05:40:59 PM

Previous topic - Next topic

ocdmonkey

Unfortunately a library I have decided to use will require me to use ->. Now, I heard that there is a plugin for MSVC that will automatically change . to -> when appropriate, and am hoping there is some way to get the same effect in Code::Blocks. Any help would be greatly appreciated.

Have a good day!
Peter

BlueHazzard

Quote from: ocdmonkey on January 29, 2015, 05:40:59 PM
Unfortunately a library I have decided to use will require me to use ->. Now, I heard that there is a plugin for MSVC that will automatically change . to -> when appropriate, and am hoping there is some way to get the same effect in Code::Blocks. Any help would be greatly appreciated.

No, there is no automated way... Probably it would be better if you understand why you have to use "." or "->", because that are two fundamental different things, and handling it wrong will give you A LOT RUNTIME ERRORS, security holes, and crashes....

greetings

ocdmonkey

I know why I have to use it, I just think it's overly clunky to type and don't understand why whoever came up with the C language decided they needed to differentiate it between normal variables and pointers.

Anyway, if there isn't a way to automatically do it, I'll just create a keyboard shortcut somehow to make it easier to type.

Have a good day!
Peter

thomas

In the OP's defense, one has to admit that there really is no good reason why there is such a distinction. The compiler already knows whether a type is of pointer type or not, so the standard could as well allow the "dot" member access operator in either case.
Of course operator overloading would have to be somewhat different too, to allow for smart pointers and such.

Alas, it is what it is  :D
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

raynebc

I was going to suggest observing C::B's code completion, but it doesn't look like that will differentiate between the two.

oBFusCATed

Some CC implementation in other IDEs have this feature, but not the one in CB. Patches welcome.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]