Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1039259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:04:39+00:00 2026-05-16T15:04:39+00:00

I add the following preprocessor code in header files all the time. #ifdef _HELLO_H_

  • 0

I add the following preprocessor code in header files all the time.

#ifdef _HELLO_H_
#define _HELLO_H_

#endif

Is there a way to do this automatically (I mean, when I load the header file for the first time, the emacs just adds the code), or manually (I mean, I have some M-x SOMETHING)?

If none exists, how can I program the elisp code to this?

  • Check if #ifdef is not defined.
  • coin the name _HELLO_H_ out of the name of the header file.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T15:04:40+00:00Added an answer on May 16, 2026 at 3:04 pm

    I use YaSnippet and it works just great. It comes default with a lot of snippets for different languages and modes, not only for C++. Plus, you can write your own templates (snippets) and even use Lisp inside them (i.e. generate file header with copyright information including current year). There is also a good documentation.

    Here is a an example of "once" snippet which is being expanded when you type "once" and hit "tab" button in cc-mode:

    #name : #ifndef XXX; #define XXX; #endif
    # --
    #ifndef ${1:_`(upcase (file-name-nondirectory (file-name-sans-extension (buffer-file-name))))`_H_}
    #define $1
    
    $0
    
    #endif
    

    And here is my "license" snippet for c++-mode which adds a copyright information with a current year:

    #name : C++ source file license
    # --
    //
    // Copyright (C) `(format-time-string "%Y" (current-time))` Bueller? Bueller?
    //
    // $Id$
    //
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I add the following to my code. // Define the input layout D3D10_INPUT_ELEMENT_DESC
I am trying to add the following code work in a php file but
How to Add following XAML based trigger to TreeView from Code behind rather than
I know I need to add the following code to change to dismax. ExtraParams
How to add The following timestamps month wise in python 2.4 i.e, all the
When I add the following lines into my code [DllImport(user32.dll)] static extern void keybd_event(byte
How can I add the following line to the header, in a component? <!--[if
I need to add the following code to the beginning of an XML file,
I created a new area admin, add following code to web.config in the admin
I create a new Django app (not project) called Bussinesses, then add following class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.