问题
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