News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

When open source file directly the auto completion doesn't work

Started by dashashi, April 22, 2012, 01:16:50 PM

Previous topic - Next topic

dashashi

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.next.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?

MortenMacFly

Quote from: dashashi on April 22, 2012, 01:16:50 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: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

dashashi

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- -|||

dashashi

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- -||

MortenMacFly

Quote from: dashashi 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- -||
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:
Quote from: MortenMacFly on April 22, 2012, 01:22:01 PM
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: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

Jenna

Quote from: dashashi on April 22, 2012, 01:37:29 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.

dashashi

I mean C::B could use the default setting of compiler(including search path) to auto complete.