hello:
in this thread ,http://forums.codeblocks.org/index.php/topic,10641.0.html (http://forums.codeblocks.org/index.php/topic,10641.0.html)
the typedef problem can not be solved.
codes like this:
#include <iostream>
using namespace std;
class Pt
{
public:
int x;
int y;
};
typedef Pt subpt;
typedef subpt sub;
int main()
{
sub pp;
pp. // not work here.
cout << "Hello world!" << endl;
return 0;
}
pp get nothing.
I think can use this patch.
but I not sure it is right or not to do this.
here is the patch.
Index: parserthread.cpp
===================================================================
--- parserthread.cpp (revision 5730)
+++ parserthread.cpp (working copy)
@@ -1707,15 +1737,60 @@
#if PARSER_DEBUG_OUTPUT
Manager::Get()->GetLogManager()->DebugLog(F(_("Adding typedef: name='%s', ancestor='%s'"), components.front().c_str(), ancestor.c_str()));
#endif
- Token* tdef = DoAddToken(tkTypedef, components.front(), lineNr, 0, 0, args);
+ Token* tdef = DoAddToken(tkClass, components.front(), lineNr, 0, 0, args);
and pp has the tip now.see the attachment.
any comment???
yes,i think so.
here is the test codes.
typedef unsigned int unlong;
typedef class cls
{
int xx;
int yy;
}clssub;
int main()
{
sub pp;
unlon
cout << "Hello world!" << endl;
return 0;
}
the unlong can be recognized correctly.
see the attachment.
my confuse is if use this ,it seems that the tkTypedef will have no use any more.
[attachment deleted by admin]
yes,i think so.
What I meant was something like this, actually:
struct tStruct
{
SomeClass* some_class;
int some_int;
void* some_void;
};
typedef struct tStruct tStruct;
...or even:
struct sStruct
{
SomeClass* some_class;
int some_int;
void* some_void;
};
typedef struct sStruct tStruct;
(Notice the different name of the struct).
I test the codes in cc-branch version without applying the patch.
class sStruct
{
SomeClass* some_class;
int some_int;
void* some_void;
};
typedef class sStruct tStruct;
int main()
{
cout << "Hello world!" << endl;
return 0;
}
it seems that the codes can not be parsed correctly.
here tStruct is recognized as a variable.
and the main is a typedef. :(
does it exist or something .
if I apply the patch , seems nothing changed :(
i will check it if i am free
[attachment deleted by admin]
I'm not quite understand you guys are taking about.
For me, I think blueshake's comment is right:
my confuse is if use this ,it seems that the tkTypedef will have no use any more.
We can just regard the "typedef" as a public derived class of the original type.
Something like this:
class sStruct
{
SomeClass* some_class;
int some_int;
void* some_void;
};
typedef class sStruct tStruct;
int main()
{
cout << "Hello world!" << endl;
return 0;
}
We can consider tStruct is a derived class from "sStruct".
That's all my want to say.
Oops - that makes me wonder. Because the used to work...?!
sorry! I don't know it doesn't work before.
@ollydbg
what we are talking about is codes like these can not be parsed correctly.
typedef class sStruct tStruct;
even i use the patch .nothing changed.
by the way . what does it mean of "Oops".
@MortenMacFly
i think the cc can use the followed patch to make codes below parsed correctly.
typedef class sStruct tStruct;
Index: parserthread.cpp
===================================================================
--- parserthread.cpp (revision 5731)
+++ parserthread.cpp (working copy)
@@ -1249,6 +1337,63 @@
struct HiddenStruct yy;
*/
+ if (m_ParsingTypedef)
+ {
+ m_Tokenizer.UngetToken();
+ break;
+ }
if (TokenExists(current, m_pLastParent, tkClass))
{
if (!TokenExists(next, m_pLastParent, tkVariable) )
+ Token* tdef = DoAddToken(tkClass, components.front(), lineNr, 0, 0, args);
- //Token* tdef = DoAddToken(tkTypedef, components.front(), lineNr, 0, 0, args);