Developer forums (C::B DEVELOPMENT STRICTLY!) > CodeCompletion redesign
extern "C" not working with CC
Loaden:
It should been fixed in next nightly build.
ollydbg:
--- Quote from: daniloz on February 11, 2011, 03:39:13 pm ---
--- Quote from: ollydbg on February 11, 2011, 03:18:28 pm ---It may be a bug, see the statement:
--- Code: ---m_Tokenizer.GetToken(); // "eat" {
--- End code ---
I think we need to check the Token is a "{" or not, am I right?
--- End quote ---
Yes, it can be a simple statement as in my example case... How do we do this check? (I am new to the CC code, sorry)
--- End quote ---
Aha, it was quite simple.
--- Code: ---// check for "C", "C++"
m_Str = m_Tokenizer.GetToken();
if (m_Str == ParserConsts::kw_C || m_Str == ParserConsts::kw_CPP)
{
wxString a;
a = m_Tokenizer.PeekToken();
if(a=="{")
{
m_Tokenizer.GetToken(); // "eat" {
DoParse(); // time for recursion ;)
}
else
{
// which means it is in your case, not a "{"
// such as: extern "C" void foo_asm(...);
// a == "void"
//do nothing here, so, both "extern" and "C" was skipped transparently.
}
}
else
{
// do nothing, just skip keyword "extern", otherwise uncomment:
//SkipToOneOfChars(ParserConsts::semicolon); // skip externs
m_Tokenizer.UngetToken();
}
m_Str.Clear();
--- End code ---
This is a brief algorithm in my mind, I haven't much time to test it, but I think you can test it. :D
remember:
GetToken() just eat the next Token
PeekToken() just do a peek at the next Token, but NOT eat the next Token.
daniloz:
--- Quote from: ollydbg on February 11, 2011, 03:59:50 pm ---This is a brief algorithm in my mind, I haven't much time to test it, but I think you can test it. :D
remember:
GetToken() just eat the next Token
PeekToken() just do a peek at the next Token, but NOT eat the next Token.
--- End quote ---
Thanks for the fix and for the explanation, the only thing I changed is that I used ParserConsts::opbrace instead of "{", so I have the following code, which works 100%!! :-)
--- Code: ---else if (token == ParserConsts::kw_extern)
{
// check for "C", "C++"
m_Str = m_Tokenizer.GetToken();
if (m_Str == ParserConsts::kw_C || m_Str == ParserConsts::kw_CPP)
{
wxString a = m_Tokenizer.PeekToken();
if (a == ParserConsts::opbrace)
{
m_Tokenizer.GetToken(); // "eat" {
DoParse(); // time for recursion ;)
}
else
{ // here we have something like extern "C" void foo_asm(...);
// a == "void"
} //do nothing here, so, both "extern" and "C" was skipped transparently.
}
else
{
// do nothing, just skip keyword "extern", otherwise uncomment:
//SkipToOneOfChars(ParserConsts::semicolon); // skip externs
m_Tokenizer.UngetToken();
}
m_Str.Clear();
}
--- End code ---
ollydbg:
@loaden
I think the rev 6984 has some problems, even the "{" is skipped, Doparse() will still be called. This is not necessary.
Navigation
[0] Message Index
[*] Previous page
Go to full version