Developers' Area
| |
Not signed in (Sign In)

Vanilla 1.1.2 is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthorlyes
    • CommentTimeApr 27th 2008
     
    Hi Jerome, i have seen something weird, when i typed a new structure like the following :

    typedef struct
    {

    int Type;
    char data[32];
    double X,Y;
    int Point;


    } FeedPacket;

    then the editor is closing ecere when i use the code completion into a function , when i typed "." to access a member into that structure, if i replace "Point" with another name it won't crash.... ???
    •  
      CommentAuthorjerome
    • CommentTimeApr 27th 2008
     
    You just found (one of many remaining) auto-completion crashes :)

    I will fix the crash. However, what happens is that Point is a registered structure in the Ecere runtime (with an int x and y members), so this would be a syntax error.

    I strongly suggest you adopt the Ecere conventions of naming variables, data members and enumeration values starting with a lowercase (and then using camelCase for multiple words), while using words starting with an uppercase for functions and classes. This will avoid this kind of problem.

    Another point here is that you are using the C style syntax for declaring your structure rather than the eC style which would go:

    struct FeedPacket
    {
    int type;
    char data[32];
    double x, y;
    int point;
    };

    The eC syntax has many advantages whereas the C style syntax is mainly supported for C compatibility. You can read more about it in the chapter on Structures in the first section of www.ecere.com/tao.pdf .
    • CommentAuthorlyes
    • CommentTimeApr 27th 2008
     
    Thank you Jerome, yes i know about the C syntax but i feel more comfortable at the moment using C structures since i am learning Ecere SDK....or maybe i am old fashioned or maybe just don't want to forget how the other part of the world is still coding lol...
    •  
      CommentAuthorjerome
    • CommentTimeApr 28th 2008 edited
     
    It's just that you can do stuff like :

    void TakeAPacket(FeedPacket packet)
    {
    printf("%d\n", packet.x);
    }

    void Test()
    {
    TakeAPacket({ x = 10 });
    }

    If you use the eC structs. Plus, eC structs are automatically useable across multiple .ec source files / dlls, without requiring header files.

    To do the same as above using C structs you'd have to do:

    void TakeAPacket(FeedPacket * packet)
    {
    printf("%d\n", packet->x);
    }

    void Test()
    {
    FeedPacket packet;
    memset(&packet, 0, sizeof(FeedPacket));
    packet.x = 10;
    TakeAPacket(&packet);
    }
    • CommentAuthorlyes
    • CommentTimeMay 2nd 2008
     
    Btw, talking about struct, if you have

    typedef struct {
    int toto;
    } MyStruct;

    MyStruct Arrayof[10];

    in one file, and if in the same project, you open a new file and you type import "file1", you can still cannot access the Arrayof, it will display an error saying "MyStruct unknown"...not very important but just wanted to report it ;)
    •  
      CommentAuthorjerome
    • CommentTimeMay 2nd 2008
     
    Yes that's because you are using C structs instead of eC structs.
    typedefs aren't available outside of an eC file.
    That is just one of the reasons why I recommend using the eC syntax.