编译器无法理解'_FILE_'为什么?

时间:2012-05-05 11:27:57

标签: c file macros

我使用C代码中的Code :: Blocks和C代码 并有一些错误..

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define SQRT(num)    \
((num>0)    ?\
(sqrt(num)): \
(printf("the number is negative")))

int main() {
    printf("The file %s is executeD \n", _FILE_);
    printf("the sqrt of number %d is %f \n",8,SQRT(8));
    printf("the sqrt of number %d is %f \n",9,SQRT(9));
    printf("the sqrt of number %d is %f \n",-9,SQRT(-9));

    return 0;
}       

3 个答案:

答案 0 :(得分:7)

__FILE__,而不是_FILE_

答案 1 :(得分:1)

宏是__FILE__(每边双下划线)

答案 2 :(得分:1)

尝试使用双下划线,例如:__FILE__