Author Topic: How to detect and auto change to ->  (Read 3052 times)

Offline ocdmonkey

  • Single posting newcomer
  • *
  • Posts: 2
How to detect and auto change to ->
« 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

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: How to detect and auto change to ->
« Reply #1 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

Offline ocdmonkey

  • Single posting newcomer
  • *
  • Posts: 2
Re: How to detect and auto change to ->
« Reply #2 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

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: How to detect and auto change to ->
« Reply #3 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
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline raynebc

  • Almost regular
  • **
  • Posts: 217
Re: How to detect and auto change to ->
« Reply #4 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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: How to detect and auto change to ->
« Reply #5 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.
(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!]