Search:

Type: Posts; User: john7

Page 1 of 3 1 2 3

Search: Search took 0.01 seconds.

  1. Replies
    8
    Views
    2,082

    ОК. what about if (val < 256) ...

    ОК. what about


    if (val < 256)
    (*((uint8_t *)generic)) = val;
    else
    (*((int *)generic)) = val;

    any way it would be properly aligned in memory? wouldn't it?
  2. Replies
    8
    Views
    2,082

    but wait a minute isn't enough? struct foo ...

    but wait a minute
    isn't enough?


    struct foo
    union {
    char *cp;
    int *ip;
    double *dp;
    } v;
  3. Replies
    8
    Views
    2,082

    yes but on 100 v I need 100 type - added RAM...

    yes but on 100 v I need 100 type - added RAM waste (in my case it's embedded, RAM limited system). I thought there is a way to avoid it.
    why the compiler rejects the cast

    (uint8_t *)iter_first =...
  4. Replies
    8
    Views
    2,082

    How can I tell what data type it points to? It's...

    How can I tell what data type it points to? It's important if I want to set a value to a variable. Strangely enough I can not cast the pointer



    (uint8_t *)iter_first = &flag[4];
  5. Replies
    8
    Views
    2,082

    Setting a value with a generic pointer.

    I have a generic pointer cause I need to work with different data types (uint8_t, int, float)


    void *iter_first;

    now I initialize it


    uint8_t flag[8];
    iter_first = &flag[4];
  6. Thank you. It's a direction.

    Thank you. It's a direction.
  7. Well... For now the braces are not mandatory in...

    Well... For now the braces are not mandatory in my script like in any grown man script :).
    That's the problem - to track the if/else depth. Otherwise the question wouldn't arise :).
  8. How to assign indexes to ' if-the-else' bundle.

    I'm stumbled at an algorithmic problem - to assign indexes.
    In a simple case it's trivial



    if (flg0 == 2) then //1
    var4=1;
    else //1
    var4=2;
  9. Replies
    8
    Views
    1,081

    Thank you. Strangely enough it demands the exact...

    Thank you. Strangely enough it demands the exact type. It could truncate the value.
  10. Replies
    8
    Views
    1,081

    What for?! When I set a break point at ...

    What for?!

    When I set a break point at
    *((float*)arg) = user_vars[num]; //num = 1
    I see - user_vars[1] is 3;
    What should be a value of arg?
  11. Replies
    8
    Views
    1,081

    void Test(int idx) { uint8_t val1, val2; ...

    void Test(int idx)
    {
    uint8_t val1, val2;

    GetArgumentFromString (functions[idx].arguments[0], &val1); //arguments[0] = "var1"
    GetArgumentFromString (functions[idx].arguments[1],...
  12. Replies
    8
    Views
    1,081

    Cast to a data type

    What's wrong in the function?



    int GetArgumentFromString(char* str, void *arg)
    {
    int num;
    char *endptr;

    if (strncmp(str, "flg", 3) == 0)
  13. Replies
    1
    Views
    57,260

    C# bitwise operations.

    In the code


    UInt64 mask = (UInt64)((message[4] << 48) | (message[5] << 40) | (message[6] << 32) | (message[7] << 24) |
    (message[8] << 16) | (message[9] << 8) |...
  14. Replies
    2
    Views
    1,764

    Thanks a lot. Looks like a brilliant idea.

    Thanks a lot. Looks like a brilliant idea.
  15. Replies
    2
    Views
    1,764

    To store a function's address as an integer

    I have a struct


    typedef struct
    {
    uint8_t type;
    uint8_t num;
    uint8_t id;

    int value;
  16. Replies
    4
    Views
    3,144

    This way it works void MyPrintf(int argc,...

    This way it works


    void MyPrintf(int argc, ...)
    {
    int i;
    int val;
    char *strp;
    VAR var;
  17. Replies
    4
    Views
    3,144

    I did it this way typedef struct { ...

    I did it this way



    typedef struct
    {
    void *value;
    int type;
    }VAR;
  18. Replies
    4
    Views
    3,144

    I see. Like %s tells it's a string. Thank you.

    I see. Like %s tells it's a string. Thank you.
  19. Replies
    4
    Views
    3,144

    Variable function arguments.

    I want to use variable arguments


    void va_test(int num_args, ...)
    {
    va_list valist;

    va_start(valist, num_args);

    for (int i = 0; i <= num_args; i++)
  20. Replies
    5
    Views
    5,403

    I see. Thank you.

    I see. Thank you.
  21. Replies
    5
    Views
    5,403

    This way I can not iterate - on dict[j]->name...

    This way

    I can not iterate - on dict[j]->name I get Error[Pe044]: expression must have pointer type

    This way

    I pass it by value - a local copy - I can not modify a member - dict[j]->value...
  22. Replies
    5
    Views
    5,403

    Passing a pointer to struct array

    I have a struct


    typedef struct
    {
    char *name;
    float value;
    void *pntr;
    uint8_t found;
    }DICTIONARY;
  23. Replies
    7
    Views
    7,150

    This variant will do. I always work with 32-bit...

    This variant will do. I always work with 32-bit platform. int will cover all values I ever need. Thank you.

    or even better


    typedef union
    {
    uint8_t *ptr;
    int16_t *ptr;
    int32_t...
  24. Replies
    7
    Views
    7,150

    I 'm very short on space. So instead allocating ...

    I 'm very short on space.
    So instead allocating


    typedef struct
    {
    void *ptr;
    int val;
    }
  25. Replies
    7
    Views
    7,150

    Using pointer address as a value

    Say I have


    void *var_ptr;

    I can initialize it with some address


    var_ptr = (int *) 100;
Results 1 to 25 of 69
Page 1 of 3 1 2 3