--------------------------------------------
Snippet:
char *value="12345";
int size;
size = sizeof(value);
printf("1.value[%s], size[%d]\n", value, size);
strcpy(value, "67890");
printf("2.value[%s], size[%d]\n", value, size);
--------------------------------------------
Result:
1.value[12345], size[4]
Segmentation fault
--------------------------------------------
Snippet:
char value[]="12345";
int size;
size = sizeof(value);
printf("1.value[%s], size[%d]\n", value, size);
strcpy(value, "67890");
printf("2.value[%s], size[%d]\n", value, size);
--------------------------------------------
Result:
1.value[12345], size[6]
2.value[67890], size[6]
2011年6月30日
Array and Pointers
標籤: Programming
2011年6月29日
error: linux/autoconf.h: No such file or directory
The kernel header file autoconf.h no longer lives at include/linux/autoconf.h.
It's now at include/generated/autoconf.h.
2011年6月22日
warning: type defaults to 'int' in declaration of 'EXPORT_SYMBOL'
warning: type defaults to 'int' in declaration of 'EXPORT_SYMBOL'
Solution:
Add "#include <linux/module.h>" in your code.
warning: implicit declaration of function 'memset'
warning: implicit declaration of function 'memset'
warning: implicit declaration of function 'open'
Solution:
Add "#include <string.h>" and "#include <unistd.h>" in your code.
error: 'TASK_INTERRUPTIBLE' undeclared (first use in this function)
When moving from v2.6.21 to v2.6.33 kernel, see errors below:
error: 'TASK_INTERRUPTIBLE' undeclared (first use in this function)
Solution:
Add "#include <linux/sched.h> " in your code.
2011年6月21日
warning: incompatible implicit declaration of built-in function 'malloc'
warning: incompatible implicit declaration of built-in function 'malloc'
Solution:
Add "#include <stdlib.h>" in your code.
訂閱:
文章 (Atom)