Remove #pragma once warnings

南楼画角 提交于 2019-11-29 02:36:05
ChronoTrigger

The common approach is to place the guard in the .h file only:

#ifndef MYFILE_H
#define MYFILE_H
// all your myfile.hpp here
#endif

or

#pragma once
// all your myfile.hpp here

The rest of files (other .cpp) should do nothing regarding the guards. You should not get warnings by doing this.

Indeed the #ifndef guard can always be used, but just to remove the warning while compiling the source which uses #pragma once I would recommend to use the -woption while compiling.

e.g. gcc -w -o <output file> <input file(s)>

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