Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

loves me some obscure error message

Name: Anonymous 2009-11-01 2:55

Ok, I've got this code (not exactly as seen here, it's much long and obviously uses real variable names etc. but I just provided the bare minimum so you can see what's going on):

void myfunc(const char *sarg)
{
        char *temp;

        temp = strtok(sarg, ".");

        /* etc.  doesn't matter what I have beyond this code */
}


I get this message:
[Warning] passing arg 1 of `strtok' discards qualifiers from pointer target type

What the hell does that mean?  I'm not too worried about it because it works fine if I just typecast sarg with (char*), but I'd like to know wtf this actually means instead of just assuming that everything will be ok as long as I typecast, since that could potentially lead to some unsafe behaviour that I can't foresee.

Name: Anonymous 2009-11-01 21:16

>>19

I use typedefs for two things: enum types and function types.


typedef enum {
    TOKEN_NUM,
    TOKEN_IDENT,
    TOKEN_LPAREN,
    TOKEN_RPAREN
} tokentype_t;

typedef struct something *(*callback_t)(int x, int y, struct obj const *restrict p, void *cxt);


Typing out "enum tokentype" doesn't appeal to me, and writing out function types for parameters or fields gets old pretty quickly.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List