R
Ravi Uday
Roman said:Hello, All!
I'm implementing function parsing config file, which look like this:
# this is comment
port=10000
path=/var/run/dump.pid
...
Declared the type
#define BUFLEN 1024
typedef struct config_s {
char parameter[BUFLEN];
void *value;
} config_t;
...
#define N 10 /* number of parameters in config file */
config_t conf[N];
...
strcpy(conf[0].parameter, "debug");
conf[0].value = value;
...
It's supposed to keep parameter name and it's value, which can be different
type (string or unsigned int), that's why I use 'void*' pointer. But at this
point I faced with the problem of type casting. If I call, for example:
strcpy(conf[5].parameter, "port");
conf[PORT].value = (unsigned short)value;
than get compiler's warning:
config.c:61: warning: cast from pointer to integer of different size
config.c:61: warning: assignment makes pointer from integer without a cast
AFAIK, casting any pointer type to (void *) need not be typecasted.
Its automatically casted for you based on the input you provide.
In your case i feel 'value' is NOT a pointer type, hence its cribbing.
Whats the data type of variable 'value' ?
Can you post a minimal code snippet which best describes the problem.
- Ravi