我搜索过SO并用谷歌搜索但我没有意识到它们。他们和他们的目的是什么?他们什么时候用?我想在现代节目和我这一代人中看到它们可能为时已晚。
其中一些是AFAIS,
/ * 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 is a thread from 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 for 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 to allocate memory for thread IDs");
return 1;
}
for (i = 0; i < n; i++)
if (error = pthread_create(tids+i, NULL, threadout, NULL)) {
fprintf(stderr, "Failed to create thread:%s\n", strerror(error));
return 1;
}
for (i = 0; i < n; i++)
if (error = pthread_join(tids[i], NULL)) {
fprintf(stderr, "Failed to join thread:%s\n", strerror(error));
return 1;
}
return 0;
}
答案 0 :(得分:8)
具体针对lint
来取消有关特定问题的评论
什么是棉绒 - 来自维基百科
在计算机编程中,lint是一个标记一些的Unix实用程序 C中可疑和不可移植的构造(可能是错误) 语言源代码;一般来说,lint或linter是任何工具 标记用任何计算机语言编写的软件中的可疑用法。 术语lint式行为有时适用于过程 标记可疑语言使用情况。类似于Lint的工具通常表现出色 静态分析源代码。
作为一个术语,皮特也可以更广泛地指代句法差异 一般来说,尤其是JavaScript和JavaScript等解释性语言 蟒蛇。例如,现代lint检查器通常用于查找代码 这与某些风格指南不符。因为这些 语言缺少编译阶段,显示之前的错误列表 执行时,它们也可以用作常见错误的简单调试器 (将语法差异显示为错误)或难以发现错误 比如heisenbugs(引起对可疑代码的关注“可能 错误“)。
项目
描述
/*NOTREACHED*/ Suppresses comments about unreachable code.
/*VARARGSNumber*/ Suppresses checking the following old style function declaration for varying numbers of arguments, but does check the data type of the first Number arguments. If you do not include a value for Number, the lint command checks no arguments (Number=0). The ANSI function prototypes should use the ellipsis to indicate unspecified parameters rather than this comment mechanism.
/*ARGSUSED*/ Suppresses warnings about function parameters not used within the function definition.
/*LINTLIBRARY*/ If you place this comment at the beginning of a file, the lint command does not identify unused functions and function parameters in the file. This is used when running the lint command on libraries.
/*NOTUSED*/ Suppresses warnings about unused external symbols, functions and function parameters in the file beginning at its point of occurrence. This is a superset of the /*LINTLIBRARY*/ comment directive, but applies also to external symbols. It is useful for suppressing warnings about unused function prototypes and other external object declarations.
/*NOTDEFINED*/ Suppresses warnings about used, but undefined external symbols and functions in the file beginning at its point of occurrence.
/*LINTSTDLIB*/ Permits a standard prototype-checking library to be formed from header files by making function prototype declarations appear as function definitions. This directive implicitly activates both the /*NOTUSED*/ and /*LINTLIBRARY*/ comment directives to reduce warning noise levels.
也许其他工具也会使用它们。
您也可以找到另一条特别评论。例如,许多IDE在注释中放置了自己的标记 - 例如,向TO DO List添加内容