In Eclipse CDT, when a header file is created, include guard defaults to a file name, for example:
[Cpp]
/*
* Test. h
*
* Created on: 2013-5-22
* Author: tao
*/
# Ifndef TEST_H _
# Define TEST_H _
# Endif/* TEST_H _*/
/*
* Test. h
*
* Created on: 2013-5-22
* Author: tao
*/
# Ifndef TEST_H _
# Define TEST_H _
# Endif/* TEST_H _*/
But for better programming specifications, we need to include guard in the full path, for example:
[Cpp]
/*
* Test. h
*
* Created on: 2013-5-22
* Author: tao
*/
# Ifndef PLATFORM_SUN6I_INCLUDE_TEST_H _
# Define PLATFORM_SUN6I_INCLUDE_TEST_H _
# Endif/* PLATFORM_SUN6I_INCLUDE_TEST_H _*/
/*
* Test. h
*
* Created on: 2013-5-22
* Author: tao
*/
# Ifndef PLATFORM_SUN6I_INCLUDE_TEST_H _
# Define PLATFORM_SUN6I_INCLUDE_TEST_H _
# Endif/* PLATFORM_SUN6I_INCLUDE_TEST_H _*/
Modify workspace/. metadata/. plugins/org. eclipse. core. runtime/. settings/org. eclipse. cdt. ui. prefs
Add or modify the following values:
[Plain]
Codetemplates. includeGuardGenerationScheme = 2
Eclipse. preferences. version = 1
Formatter_settings_version = 1
Codetemplates. includeGuardGenerationScheme = 2
Eclipse. preferences. version = 1
Formatter_settings_version = 1
The definition of codetemplates. includeGuardGenerationScheme is as follows:
0 capital file name, I. e. FILE_H _
1 generate UUID, I. e. ha9bacdc2_c883_433369846a_e3769e132e8a
2 capital full path, I. e. SRC_INCLUDE_FILE_H _