Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fast way to insert include guard in Visual Studio

I want to automatically insert include guards into newly created header files in Visual Studio 2012. Is there any predefined snippet for this purpose?

EDIT: I'm aware of #pragma once and its wide support by compilers. But our coding style forces me to use include guards.

like image 640
Ivan Ivanov Avatar asked Jun 07 '13 07:06

Ivan Ivanov


2 Answers

In visual studio 2012 use the key combinations

Ctrl+K,Ctrl+S

It allows you to surround selected code with code snippets such as:

#if, #ifdef, #ifndef, if, class, do, enum, and many more

.. or specify your own: http://msdn.microsoft.com/en-us/library/ms165394.aspx

like image 59
Enigma Avatar answered Oct 16 '22 23:10

Enigma


#pragma once?

But no, I'm not aware of anything that automatically inserts the #ifndef, etc. for you.

like image 1
Joey Avatar answered Oct 16 '22 23:10

Joey