Override #pragma once with standard #ifndef MS-VC++
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
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.
精彩评论