ОК. 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?
Type: Posts; User: john7
ОК. 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?
but wait a minute
isn't enough?
struct foo
union {
char *cp;
int *ip;
double *dp;
} v;
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 =...
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];
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];
Thank you. It's a direction.
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 :).
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;
Thank you. Strangely enough it demands the exact type. It could truncate the value.
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?
void Test(int idx)
{
uint8_t val1, val2;
GetArgumentFromString (functions[idx].arguments[0], &val1); //arguments[0] = "var1"
GetArgumentFromString (functions[idx].arguments[1],...
What's wrong in the function?
int GetArgumentFromString(char* str, void *arg)
{
int num;
char *endptr;
if (strncmp(str, "flg", 3) == 0)
In the code
UInt64 mask = (UInt64)((message[4] << 48) | (message[5] << 40) | (message[6] << 32) | (message[7] << 24) |
(message[8] << 16) | (message[9] << 8) |...
Thanks a lot. Looks like a brilliant idea.
I have a struct
typedef struct
{
uint8_t type;
uint8_t num;
uint8_t id;
int value;
This way it works
void MyPrintf(int argc, ...)
{
int i;
int val;
char *strp;
VAR var;
I did it this way
typedef struct
{
void *value;
int type;
}VAR;
I see. Like %s tells it's a string. Thank you.
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++)
I see. Thank you.
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...
I have a struct
typedef struct
{
char *name;
float value;
void *pntr;
uint8_t found;
}DICTIONARY;
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...
I 'm very short on space.
So instead allocating
typedef struct
{
void *ptr;
int val;
}
Say I have
void *var_ptr;
I can initialize it with some address
var_ptr = (int *) 100;