赞
踩
In file included from main.c:3: b/test.h:3: warning: "PI" redefined 3 | #define PI 3.1415926 | In file included from main.c:2: a/test.h:3: note: this is the location of the previous definition 3 | #define PI 3.14 |
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
在多个目录下定义头文件时如果有相同头文件时候#pragma once会警告并且把后面的覆盖前面的,而#ifndef则不会进入第二个。
main.c
#include <stdio.h>
#include "a/test.h"
#include "b/test.h"
int main(int argc, char const *argv[])
{
printf("%lf\n",PI);
return 0;
}
a/test.h
#pragma once
#define PI 3.14
// #ifndef _TEST_H_
// #define _TEST_H_
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。