User Profile

Collapse

Profile Sidebar

Collapse
MTsoul
MTsoul
Last Activity: Feb 25 '09, 04:43 AM
Joined: Nov 6 '08
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • So what should I use? What was it backward compatible for? Isn't the C standard pretty, uh, standard?
    See more | Go to post

    Leave a comment:


  • MTsoul
    started a topic Why does WinAPI redefine (typedef) basic types?

    Why does WinAPI redefine (typedef) basic types?

    I see the point to defining things like LPSTR for brevity in code. But what's the point of typedef void VOID and char CHAR? It looks strange (no syntax highlighting) and it makes the programmer doubt basic assumptions of the type. It's not like these types would change in the future - otherwise the assumptions of void and char would be totally invalid. So what's the rationale behind this?
    See more | Go to post

  • MTsoul
    replied to Registering sub-classes to a central location
    in C
    Thanks. I thought about that but decided to go with function pointers. Factory classes have the same problem as the one I described. I still need to instantiate the Factory classes to make new objects. Function pointers take care of that problem I think.
    See more | Go to post

    Leave a comment:


  • MTsoul
    replied to Registering sub-classes to a central location
    in C
    The question is how? The interface is great if I have an object of the subclass, in which case the manager can manipulate the object with the interface. How do I address the subclass if no objects have been created?

    Code execution starts from the manager, which should then instantiate a bunch of subclasses (through the interface or some other mechanism). How can this be done without statically instantiating the subclasses like the code...
    See more | Go to post

    Leave a comment:


  • MTsoul
    started a topic Registering sub-classes to a central location
    in C

    Registering sub-classes to a central location

    Here is an interesting problem I've come across. It's more on the use of some C++ design patterns.

    Scenario: There is an interface. Sub-classes implement this interface. There is a manager that should iterate through these sub-classes and issue commands, etc.

    Problem: How is it possible to register these sub-classes to the manager at compile time?

    I have tried doing something like:

    Code:
    typedef struct
    ...
    See more | Go to post

  • Oh that's no fun. Is there a per-file or per-symbol compiler option to disable that? I think GCC 4 has one...

    Thanks for the confirmation though! I wish the compiler would tell me about things like this when it happens.
    See more | Go to post

    Leave a comment:


  • sizeof(struct) giving unexpected sizes. Memory alignment issues?

    I noticed some quirks with C++ (not sure if this is the same for C).

    I have:

    Code:
    struct A {
        char a[14];
    };
    
    struct B {
        char b[16];
    };
    
    struct C {
        struct A a;
        struct B b;
    };
    sizeof(C) produces 32, which is mind boggling. Is the C++ compiler trying to align it to the memory structure? This is god awful for doing things...
    See more | Go to post
No activity results to display
Show More
Working...