Author Topic: When open source file directly the auto completion doesn't work  (Read 4519 times)

Offline dashashi

  • Single posting newcomer
  • *
  • Posts: 4
First sorry for my poor english.
I usually write code for some microcontrollers such as PIC and stm32, and the editor of their IDE is head to use, but I have to download the program and debug under their IDE. So I want to use codeblocks just as a editor nor a IDE.
I added the path of header file in the way mentioned http://forums.codeblocks.org/index.php?topic=10933.0 and if I launch CodeBlocks first and then open the source file from CodeBlocks, the auto completion works fine. While if I open source file directlly in the explorer(I set the CodeBlocks as default editor of cpp file), the auto completion just doesn't work.
Is it a bug or something wrong in my setting?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: When open source file directly the auto completion doesn't work
« Reply #1 on: April 22, 2012, 01:22:01 pm »
Is it a bug or something wrong in my setting?
If you just open a file it is w/o a project. Thus, C::B cannot know the configuration for that file, e.g. what compiler it uses, what include folders are needed and so on. Therefore CC is disabled, or at least reduced to a minimum.

You need a properly setup project for this to work.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline dashashi

  • Single posting newcomer
  • *
  • Posts: 4
Re: When open source file directly the auto completion doesn't work
« Reply #2 on: April 22, 2012, 01:26:09 pm »
But if I open the file (with out project) in C::B, It just works fine.
And I found after open the file directly, Press F9 to compile, then modify the file a little, save it, the code completion works just fine again- -|||

Offline dashashi

  • Single posting newcomer
  • *
  • Posts: 4
Re: When open source file directly the auto completion doesn't work
« Reply #3 on: April 22, 2012, 01:37:29 pm »
When there's no project, C::B use GCC as default compiler and why can't it use GCC's global setting of header files to help me auto complete- -||

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: When open source file directly the auto completion doesn't work
« Reply #4 on: April 22, 2012, 02:59:14 pm »
When there's no project, C::B use GCC as default compiler and why can't it use GCC's global setting of header files to help me auto complete- -||
Well it does (as you had just pointed out), but never to an extend as it is possible with a project. That's what I meant with:
Therefore CC is disabled, or at least reduced to a minimum.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: When open source file directly the auto completion doesn't work
« Reply #5 on: April 22, 2012, 03:02:27 pm »
When there's no project, C::B use GCC as default compiler [...]

That's not absolutely true, it should use the compiler set as default compiler, it's gcc as default, but can be changed by the user.

Offline dashashi

  • Single posting newcomer
  • *
  • Posts: 4
Re: When open source file directly the auto completion doesn't work
« Reply #6 on: April 23, 2012, 02:53:50 am »
I mean C::B could use the default setting of compiler(including search path) to auto complete.