Code::Blocks Forums

User forums => Help => Topic started by: lechoo on February 28, 2007, 03:49:11 PM

Poll
Question: c++ parser
Option 1: 1 votes: 0
Option 2: 2 votes: 2
Title: c++ parser
Post by: lechoo on February 28, 2007, 03:49:11 PM
Hello
I have problem with parser.
When I write

WNDCLASSEX wincl;

and want use

wincl.

it should show teh members of this struct, but id don't show ;/

Sorry for my english
Title: Re: c++ parser
Post by: raph on February 28, 2007, 07:34:21 PM
Codecompletion pugin doesn't support structs currently, sorry :(.
Title: Re: c++ parser
Post by: MortenMacFly on February 28, 2007, 07:43:33 PM
Quote from: raph on February 28, 2007, 07:34:21 PM
Codecompletion pugin doesn't support structs currently, sorry :(.
That's not true. structs are very well supported, if you define them like:

struct tMyStruct
{
  int MyInt;
  double dMyDouble;
  bool MyBool;
};
typedef struct tMyStruct tMyStruct;

tMyStruct. will then perfectly code-complete. If you can do the same with WNDCLASSEX (not sure about that) It'll work, too.

With regards, Morten

Ps.: BTW: lechoo: This poll is non-sense. Why did you choose to create such a poll instead of a normal post?!
Title: Re: c++ parser
Post by: raph on February 28, 2007, 08:41:49 PM
If you write
struct tMyStruct_
{
  int MyInt;
  double dMyDouble;
  bool MyBool;
};
typedef struct tMyStruct_ tMyStruct;



tMyStruct s;
s.

won't be completed. Same with
struct tMyStruct_ s;
s.


What will be completed is
tMyStruct_ s;
s.

although I think it isn't valid c++ (I just tried it and gcc compiled without errors/warnings :shock:)
For the windows-structs it isn't that easy, since they are defines either for the -A or for the -W version (e.g. WNDCLASSEXA) (depending whether you are using unicode).
Code (winuser.h) Select
#ifdef UNICODE
#define EDITWORDBREAKPROC EDITWORDBREAKPROCW
...
typedef WNDCLASSW WNDCLASS,*LPWNDCLASS,*PWNDCLASS;


Anyway, I'm glad that codecompletion does work for structs. I'm going to change my structs, wich are happily not that many :D

Greetings raph
Title: Re: c++ parser
Post by: TDragon on February 28, 2007, 08:57:42 PM
Quote from: raph on February 28, 2007, 08:41:49 PM
although I think it isn't valid c++
It is valid C++; in C++ a struct is identical to a class, with the exception of the default member access being public instead of private.

C++ may use this idiom:

struct mystruct
{
    ...
};
...
mystruct s;

but C must use an idiom such as this:

typedef struct mystruct_
{
    ...
} mystruct;
...
mystruct s;

or this:

struct mystruct
{
    ...
};
typedef struct mystruct mystructdef;
...
struct mystruct s;
mystructdef s;
Title: Re: c++ parser
Post by: raph on February 28, 2007, 09:25:40 PM
Ah thanks, that explains my confusion  :)