I'm using windows, (c::b build SVN 8150) and can't seem to get local variables to be completed.
I'm quite new to c::b, (moved from eclipse), so I might be doing something wrong, but everything I saw in the code completion plugin settings said nothing about local (automatic) variables.
For example,
wakeup interrupt (USCIAB0RX_VECTOR) process_RX (void)
{
int receive_buffer = 0;
recei //hitting ctrl+space here doesn't bring up the variable name.
}
I'm using c::b to program msp430 microcontrollers using mspgcc, and this probably has something to do with that "weird" function declaration (declares an interrupt handler) which the code completion plugin can't parse correctly, because the function doesn't show up in code completion toolbar's function list either.
btw, without macros function call looks like this:
__attribute__((wakeup)) void __attribute__((interrupt (x))) process_RX(void)
if that makes some difference..
Thanks in advance!
I'm using windows, (c::b build SVN 8150) and can't seem to get local variables to be completed.
I'm quite new to c::b, (moved from eclipse), so I might be doing something wrong,
Welcome!!!
but everything I saw in the code completion plugin settings said nothing about local (automatic) variables.
Yes, there is no options for local(automatic variables).
For example,
wakeup interrupt (USCIAB0RX_VECTOR) process_RX (void)
{
int receive_buffer = 0;
recei //hitting ctrl+space here doesn't bring up the variable name.
}
I'm using c::b to program msp430 microcontrollers using mspgcc, and this probably has something to do with that "weird" function declaration (declares an interrupt handler) which the code completion plugin can't parse correctly, because the function doesn't show up in code completion toolbar's function list either.
Yes, you are right. The code:
wakeup interrupt (USCIAB0RX_VECTOR) process_RX (void)
is not a valid function definition. So, CB does not recognize it.
btw, without macros function call looks like this:
__attribute__((wakeup)) void __attribute__((interrupt (x))) process_RX(void)
if that makes some difference.
I think you can add some custom string replacement rules for this kind of parsing, you can see this page for some details.
http://wiki.codeblocks.org/index.php?title=Code_Completion_Design#replacement_rules
You can basically strip the strings like "__attribute__((wakeup))" and "__attribute__((interrupt (x)))", so the parser see these code like below:
This should be a valid function declaration/definition, because it have some string mode like "AAAA BBBBB(CCCC)". :)
Awesome, sounds very promising! Thanks a lot!
because the "x" in interrupt(x) changes, can i do something like strip all strings starting with "__attribute__"?
As for the * rule, it is able to strip parentheses and such, but can it also strip what is inside the ()?
Hi, those rules were added years ago, it was mainly in the code completion's source code:
void Tokenizer::MacroReplace(wxString& str)
Which is under:
svn.berlios.de/svnroot/repos/codeblocks/trunk/src/plugins/codecompletion/parser/tokenizer.cpp
So, if you need any improvement, patches were welcome. :)
In-fact, I would like to implement these rules just like we define a real macro, such as:
#define _GLIBCXX_BEGIN_NESTED_NAMESPACE(a,b) namespace a {
So, it will be more clean then the currently way:
Current replace rule (http://wiki.codeblocks.org/index.php?title=Code_Completion_Design#AAAAA_-.3E_.2BBBBBB)
or is it possible to see to the parser output somehow so I can try different rules?
If you can build c::b yourself, there is a cc_test project(cbp), then you can enable the TRACE, and see what the parser do when parsing the file.
EDIT:
One more question..
Does the parser read the code "as is", or does it run the preprocessor first?
There is no "preprocessor" stage in our parser, this takes a lot of time, we even don't expand the #include directive, the parser only parse each file(header file or source file) once, and it did some macro replacement in its tokenizer, also it guess whether it hit some macros in some heuristic way. Also, our parser is only a very simple c++ parser, we don't use semantic check or other complex things.
EDIT 2:
I managed to achieve wanted result by adding rules
"wakeup -> "
and
"interrupt -> void"
because the token created from interrupt(USCIAB0RX_VECTOR) is apparently only "interrupt", it got replaced nicely!
Thanks for your help!
Grad to see you solved the problem. :)