Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

Code completion doesnt follow #include in struct

(1/8) > >>

zacaj:
I posted this in the bug tracker, and was told to post here

object.h:

--- Code: ---typedef struct
{
#include "object_struct.h"
} Object;
--- End code ---
object_struct.h:

--- Code: ---    vec3f pos; ///< The 3D position of the object
    vec3f lpos; ///< The 3D position of the object last update
    float r; ///< The radius of the Object
    uchar type; ///< Used to identify if the Object has been inherited
Quaternion q; ///< The rotation of the Object, as a Quaternion
void *data; ///< Pointer to the data used by this object for rendering

--- End code ---
main.c:

--- Code: ---#include "object.h"

int main()
{
  Object *object=malloc(sizeof(Object));
  object->ty//HERE
}
--- End code ---
after typing ty at //HERE type will not be suggested, nor will any other member of Object

This is even more annoying if you have another object 'inherit' Object:
enemy.h:

--- Code: ---typedef struct
{
  #include "object_struct.h"
  float hp;
} Enemy
--- End code ---
main.c:

--- Code: ---#include "enemy.h"

int main()
{
  Enemy *enemy=malloc(sizeof(Enemy));
  object->//HERE
}
--- End code ---
Code completion will automatically complete with hp (I know this can be turned off, but its useful in lots of other cases)

oBFusCATed:
C::B version, OS version?
If C::B is <=10.05 then try some of the latest nightlies...

ollydbg:
@zacaj
Ok, I know why cc does not show it's member.
Because Currently, CC's parser dose not do a full preprocessor. I mean, both files were parsed separately, so, the members in "object_struct.h" will be added to "global namespace" instead of the struct.  :D

It is too hard to implement a full parser. so the bug can't finished soon. The most reasonal way in the feature was: gcc/clang, those two were all compilers, so they do a full parse on your code.

zacaj:
C::B rev 6992, Windows 7 32 bit

Is the CC parser custom?  A full preprocessor does seem like it would be complex, but it doesnt seem (at least in my mind, I havent looked at the code) like it should be that hard to jump into another file if its included and just keep reading from there

oBFusCATed:
zacaj: Why don't you use proper inheritance? Yes, C has it, too.

It is something like:


--- Code: ---typedef struct A
{
     members of A;
};

typedef struct B {
    A base;
    members of B;
};

--- End code ---

Navigation

[0] Message Index

[#] Next page

Go to full version