是#include之前#ifdef /#define Include-Guard好吗? [英] Is an #include before #ifdef/#define Include-Guard okay?

查看:331
本文介绍了是#include之前#ifdef /#define Include-Guard好吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我总是把 #include 放在 #ifdef / #define Include-Guard。现在我的IDE(Qt Creator)的重构机制放在Include-Guard之前例如

I always placed my #include after the #ifdef/#define Include-Guard. Now the refactor mechanism of my IDE (Qt Creator) put it before the Include-Guard e.g.

#include "AnotherHeader.h"

#ifndef MYHEADER_H
#define MYHEADER_H

推荐答案

如果有问题的标题包括卫士本身,你不会运行成为问题。把它放在包含守卫可能会加速编译。编译器没有看到的东西需要较少的编译时间,即使它不会产生任何错误。

If the header in question has include guards itself, you won't run into problems. Putting it inside the include guards may still speed up compilation. Something the compiler does not see takes less time to compile, even if it does not produce any errors.

这篇关于是#include之前#ifdef /#define Include-Guard好吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆