Override #pragma once with standard #ifndef MS-VC++

ε祈祈猫儿з 提交于 2019-12-24 03:14:18

问题


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

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

回答1:


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.

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.



来源:https://stackoverflow.com/questions/6566595/override-pragma-once-with-standard-ifndef-ms-vc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!