使用标准 #ifndef MS-VC++ 覆盖 #pragma 一次 [英] Override #pragma once with standard #ifndef MS-VC++

查看:28
本文介绍了使用标准 #ifndef MS-VC++ 覆盖 #pragma 一次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我还没有看到这个问题的任何答案(这可能意味着它是不允许的),但我想我还是会问.

I haven't seen any answers to this question (which probably means that it's not allowed) but I thought I'd ask anyway.

有什么方法可以覆盖使用 MS Visual-C++ 创建的 .h.hpp 文件中 #pragma once 的自动生成使用便携式友好预处理器指令的标准头保护?

Is there any way to override the automatic generation of #pragma once in .h or .hpp files created using MS Visual-C++ to use the standard header guards of using portable friendly preprocessor directives?

#ifndef _V_DESCRIPTOR_ 
#define _V_DESCRIPTOR_
 // some code here
#endif

推荐答案

为了回答您真正的问题,我认为 Visual Studio 没有任何选项,但使用 Visual Studio Extensibility Toolkit 会非常简单,所以我确定有人写了一个可以下载的宏.环顾工具 -> 扩展管理器 -> 在线图库,您可以安装大量免费插件目录.

To answer your real question, I don't think Visual Studio has any option for that, but it would be pretty simple to do with the Visual Studio Extensibility Toolkit, so I'm sure someone has written a macro you can download. Look around Tools -> Extension Manager -> Online Gallery, there's a large catalog of free addins you can install.

例如,Zoom C++ 类向导 似乎生成两种样式的包含保护.但我从未使用过它,所以我无法以一种或另一种方式提出建议.

For example, the Zoom C++ Class Wizard appears to generate both styles of include guard. But I've never used it so I can't make a recommendation one way or the other.

这篇关于使用标准 #ifndef MS-VC++ 覆盖 #pragma 一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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