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

2019-07-15 11:12发布

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条回答
该账号已被封号
2楼-- · 2019-07-15 11:58

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.

查看更多
登录 后发表回答