When recently adding the abbreviations snippet I encountered a problem with gcc -c -g -O2 -Wall handler.c handler.c:62: conflicting types for `isname' handler.h:25: previous declaration of `isname' so I looked into the h file and seen that it was making the isname a const char and the snippet used a plain char. I kind of fixed it by adding a const onto the chars in the snippet, but I get the following gcc -c -g -O2 -Wall handler.c handler.c: In function `isname': handler.c:68: warning: passing arg 1 of `strtok' discards `const' from pointer target type handler.c:72: warning: passing arg 1 of `free' discards `const' from pointer target type handler.c:75: warning: passing arg 1 of `free' discards `const' from pointer target type When I compile and run, you can abbreviate words ok, and I haven't noticed anything bad going on. So is this a bad warning or not? Here is the complete code I've added /* snippet by From: Jvrgen Zigge Sigvardsson <di4sig@cse.hks.se> Subject: Abbreviations for objects, mobs and players. */ #define WHITESPACE " \t" int isname(const char *str, const char *namelist) { const char *newlist; const char *curtok; newlist = strdup(namelist); /* make a copy since strtok 'modifies' strings */ for(curtok = strtok(newlist, WHITESPACE); curtok; curtok = strtok(NULL, WHITESPACE)) if(curtok && is_abbrev(str, curtok)) { free(newlist); return 1; } free(newlist); return 0; } Any thoughts would be appreciated. c +------------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html | +------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 04/10/01 PDT