|
|
源代码assert.c:
- #include <stdio.h>
- #include <math.h>
- #include <stdlib.h>
- #include <assert.h>
- double my_sqrt(double x)
- {
- assert(x >= 0.0);
- return sqrt(x);
- }
- int main()
- {
- printf("sqrt +2 = %g\n", my_sqrt(2.0));
- printf("sqrt -2 = %g\n", my_sqrt(-2.0));
- exit(0);
- }
复制代码
------------------------------------------------------------------
编译过程:
- [zxz@localhost chapter10]$ gcc -Wall -o assert assert.c
- /tmp/ccGnOiR2.o(.text+0x45): In function `my_sqrt':
- assert.c: undefined reference to `sqrt'
- collect2: ld 返回 1
- [zxz@localhost chapter10]$
复制代码
书上的例子啊,何解? |
|