Author Topic: Syntax checking  (Read 8713 times)

Offline Valhalas

  • Single posting newcomer
  • *
  • Posts: 2
Syntax checking
« on: April 10, 2012, 11:13:05 pm »
Hello, just started using codeblocks today and I was wondering if there is some option or plug-in to enable code "auto" syntax check. f.e. if I type in some undefined variable "sdfsdf = 10;" and push enter or some time passes, because as of now it seems only do syntax check, when I build the project.

Offline Freem

  • Almost regular
  • **
  • Posts: 219
Re: Syntax checking
« Reply #1 on: April 12, 2012, 03:34:23 pm »
There is not.

And I am fear that it will not come tomorrow, because parsing cpp files is really hard. Think about that, you can have nested typedef, macros, templates and classes. This is not so uncommon, and C::B is not at the moment able to parse correctly such kind of things, even for code completion.
So, for syntax check, the only way is to compile.

C++ is not java, there are many steps to make an application. In short (notice that for template, I am not sure about the priority):
_ macro parser phase 1
_ macro parser phase 2
_ template parsing
_ sometimes compilation of header files (pre-compiled headers)
_ compilation of each cpp file
_ linking of all object files

And remember when you compile projects. It take several seconds, even for short ones, and for huge ones, it can take hours. Integrating such feature would kill your processor, ram and hard-disk quickly. (And C::B is my personal favorite IDE because it is lightweight ;) )
So, such kind of feature is possible, but will dramatically slow your computer. Even microsoft visual C++ does not have this feature, at least in 2008 version. (Or I do not know where it is hidden)

Offline Valhalas

  • Single posting newcomer
  • *
  • Posts: 2
Re: Syntax checking
« Reply #2 on: April 12, 2012, 09:58:22 pm »
Fair enough, I guess I can live without it.

It just seems like a common thing to have as it was (more or less) in all the other programs I was/am using with C++. (Xcode, QT creator, Eclipse with plug-in for C++) Pretty sure it does auto-check in visual studio too, however I can't guarantee as I haven't used it for a long time. Though it sometimes can get pretty annoying, so, I guess, only doing a check when prompted has it's own benefits :)

Offline jarod42

  • Multiple posting newcomer
  • *
  • Posts: 87
Re: Syntax checking
« Reply #3 on: April 13, 2012, 12:25:10 pm »
VS2010 doesn't compile automatically, but can sometime underlines (like spell-checker does) some "simple" errors (undeclared variable).

Offline Freem

  • Almost regular
  • **
  • Posts: 219
Re: Syntax checking
« Reply #4 on: April 13, 2012, 05:22:35 pm »
I have never seen that. But maybe it is because I always use code completion to fully name my variables :D

However, sounds like a nice feature. Maybe someday one will want to implement it.