Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: ocdmonkey on January 29, 2015, 05:40:59 pm

Title: How to detect and auto change to ->
Post by: 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.

Have a good day!
Peter
Title: Re: How to detect and auto change to ->
Post by: BlueHazzard on January 29, 2015, 06:25:11 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
Title: Re: How to detect and auto change to ->
Post by: ocdmonkey on January 29, 2015, 07:25:30 pm
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
Title: Re: How to detect and auto change to ->
Post by: thomas on January 29, 2015, 07:34:25 pm
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
Title: Re: How to detect and auto change to ->
Post by: raynebc on January 29, 2015, 08:32:33 pm
I was going to suggest observing C::B's code completion, but it doesn't look like that will differentiate between the two.
Title: Re: How to detect and auto change to ->
Post by: oBFusCATed on January 29, 2015, 08:40:06 pm
Some CC implementation in other IDEs have this feature, but not the one in CB. Patches welcome.