c - /* ARGSUSED */ and other special comments -
i've searched on , googled don't meanings of them. , purposes? when used? think maybe i'm late see them in modern-day programming , in generation.
some of them afais,
example code /* argsused */
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <pthread.h> #define bufsize 1024 #define ten_million 10000000l /* argsused */ void *threadout(void *args) { char buffer[bufsize]; char *c; struct timespec sleeptime; sleeptime.tv_sec = 0; sleeptime.tv_nsec = ten_million; snprintf(buffer, bufsize, "this thread process %ld\n", (long)getpid()); c = buffer; /*****************start of critical section ********************/ while (*c != '\0') { fputc(*c, stderr); c++; nanosleep(&sleeptime, null); } /*******************end of critical section ********************/ return null; } int main(int argc, char *argv[]) { int error; int i; int n; pthread_t *tids; if (argc != 2){ /* check valid number of command-line arguments */ fprintf (stderr, "usage: %s numthreads\n", argv[0]); return 1; } n = atoi(argv[1]); tids = (pthread_t *)calloc(n, sizeof(pthread_t)); if (tids == null) { perror("failed allocate memory thread ids"); return 1; } (i = 0; < n; i++) if (error = pthread_create(tids+i, null, threadout, null)) { fprintf(stderr, "failed create thread:%s\n", strerror(error)); return 1; } (i = 0; < n; i++) if (error = pthread_join(tids[i], null)) { fprintf(stderr, "failed join thread:%s\n", strerror(error)); return 1; } return 0; }
it specific lint suppress comments particular issue
what lint - wikipedia
in computer programming, lint unix utility flags suspicious , non-portable constructs (likely bugs) in c language source code; generically, lint or linter tool flags suspicious usage in software written in computer language. term lint-like behavior applied process of flagging suspicious language usage. lint-like tools perform static analysis of source code.
lint term can refer more broadly syntactic discrepancies in general, in interpreted languages javascript , python. example, modern lint checkers used find code doesn't correspond style guidelines. because these languages lack compiling phase shows list of errors prior execution, can used simple debuggers common errors (showing syntactic discrepancies errors) or hard find errors such heisenbugs (drawing attention on suspicious code "possible errors").
item
description
/*notreached*/ suppresses comments unreachable code. /*varargsnumber*/ suppresses checking following old style function declaration varying numbers of arguments, check data type of first number arguments. if not include value number, lint command checks no arguments (number=0). ansi function prototypes should use ellipsis indicate unspecified parameters rather comment mechanism. /*argsused*/ suppresses warnings function parameters not used within function definition. /*lintlibrary*/ if place comment @ beginning of file, lint command not identify unused functions , function parameters in file. used when running lint command on libraries. /*notused*/ suppresses warnings unused external symbols, functions , function parameters in file beginning @ point of occurrence. superset of /*lintlibrary*/ comment directive, applies external symbols. useful suppressing warnings unused function prototypes , other external object declarations. /*notdefined*/ suppresses warnings used, undefined external symbols , functions in file beginning @ point of occurrence. /*lintstdlib*/ permits standard prototype-checking library formed header files making function prototype declarations appear function definitions. directive implicitly activates both /*notused*/ , /*lintlibrary*/ comment directives reduce warning noise levels. maybe other tools use them well.
you may find special comments well. example many ides have own tokens placed in comments - example add to list
Comments
Post a Comment