In Eclipse CDT, modify include guard to include the full path

Source: Internet
Author: User

 


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 _

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.