Git Product home page Git Product logo

cppincludeguard's Introduction

cppincludeguard's People

Contributors

akiramiyakoda avatar dependabot[bot] avatar erkan-ozkan avatar ho-cooh avatar philanatidae avatar sleiner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

cppincludeguard's Issues

Command 'Insert C/C++ Include Guard' resulted in an error (command 'extension.insertIncludeGuard' not found)

The title pretty much says it all ๐Ÿ˜†

Anyway, here's my environment configuration for some additional insight:

Host OS: Windows 10 build 2004
Remote Development: SSH
Remote OS: Ubuntu 16.04 (It's actually a docker container, but it shouldn't matter)
VSCode Version: 1.46.1
C/C++ Include Guard Version: 1.0.0

And that's pretty much it - I haven't configured any settings yet, just opened a header file and hit the 'Insert C/C++ Include Guard' from the command palette.

Could you describe how to use it?

I can see some gifs that open some searchable lists with entries like "Insert or update C++ include guard". But there's no explanation how to open this list.

[Suggestion] Some changes

I'd like to suggest you remove \n after #endif /*filename */, add one blank line and put the cursor at the 4th line just like on the screenshot below
image

Better multi-root workspace support

Hi,

I would like to setup a Prefix option for a particular project folder. I like the simplicity of using the filename option, but in order to avoid conflicts, I would like to prefix it with the project name.

When I add the following to the folder's .vscode/settings.json it works pretty well using a single folder workspace, but it doesn't with a multi-root workspace.

"C/C++ Include Guard.Prefix": "A_PREFIX_"

According to this and considering how the code of this extension fetches the settings, it should work pretty out of the box by simply adding a "resource" scope to the properties in the package.json file. However it didn't work by simply editing the package.json in my vscode extension's installation directory.

New Lines / Cursor location

is there anyway to have it insert a few blank lines before the endif and to move the cursor to one of those lines?

[Feature Request] Allow automatic 'extern "C"' guard in header files

Hi there,

I use your plugin all the time - its an incredibly useful tool. In one of my more recent projects, I realized I need to mix C and C++, so now I need to edit about 100 header files to add the extern C guard to C function prototypes, i.e.

#ifdef __cplusplus
extern "C" {
#endif

// List of C function prototypes

#ifdef __cplusplus
}
#endif

It struck me that your plugin would be the perfect place to accomplish such a think automatically - seeing as how you already have the mechanism constructed to surround code with include guards.

What do you think? I would be willing to submit a pull request myself if time allows.

V1.3.0 breaks "compare changes" of header files

The latest update (to V1.3.0) breaks "compare changes" under VSCode source control navigation. It appears that .h files no longer show a diff view, rather each time "compare changes" is selected, the displayed file will alternate between foo.h (git) (read-only) and foo.h, with a diff view very briefly flashing into view. Clicking on the file again while the diff view is being loaded sometimes causes a successful diff to be displayed.

Rolling this extension back to V1.2.1 resolves the problem.

OS: Windows 10

VSCode version information:
Version: 1.55.0 (user setup)
Commit: c185983a683d14c396952dd432459097bc7f757f
Date: 2021-03-30T16:01:55.261Z
Electron: 11.3.0
Chrome: 87.0.4280.141
Node.js: 12.18.3
V8: 8.7.220.31-electron.0
OS: Windows_NT x64 10.0.19042

Allow to specify number of spaces between #endif and the comment

For the project I am working on, it has to be

#endif  // comment

with two spaces, the extension only allows one. Alternately, it could detect the number of spaces and not change it when updating the line, but then you still have to update it manually (or with Format Document, etc.) once.

Publish to Open VSX registry.

From https://github.com/eclipse/openvsx :

Open VSX is a vendor-neutral open-source alternative to the Visual Studio Marketplace. It provides a server application that manages VS Code extensions in a database, a web application similar to the VS Code Marketplace, and a command-line tool for publishing extensions similar to vsce.

This will allow the extension to be available on VsCode-based editors that come with a configuration that enables Open VSX, including the popular VsCodium and the code package from ArchLinux.

Is it possible to have a subfolder prefix for all folders?

I'm trying to setup my guards like this for "/Folder1/Folder2/File-Name With Spaces.h"
"ProjectName__Folder1__Folder2__File_Name_With_Spaces_h__"
As close as I have gotten so far.
"ProjectName__FOLDER1_FOLDER2_FILE_NAME_WITH_SPACES_H__"
I can get ProjectName with a prefix. I can get the 2 underscores at the end with a suffix. I can get the file path.

So my two questions/feature suggestions are.

  1. Don't change file/folder name case.
  2. Have a prefix for all subfolders so I can add the extra underscore.
  3. A prefix/suffix for the comment at the end. I'm looking for something like "// End !defined(MY_INCLUDE_GUARD)"

How to remove prefixes directory?

Hello,

Let say I want to create include guard for this file: src/db/db.hpp

Want I want is something like this:

#ifndef DB_DB_HPP
#define DB_DB_HPP
#endif

You will notice there is no src prefixes. I'm tried to adjust C/C++ Include Guard.Path Depth but I can't make it work. So my question is how to achieve this result?

Macro type: filename not works

After setting Macro type as filename, extension doesn't makes valid macro.

#ifndef 
#define 

// contents

#endif /*  */

After some crude debugging, I found baseUri is undefined.
Screen Shot 2020-02-07 at 7 27 03 PM

Not sure why this happens. Maybe OS incompatibility?

my environment:

Version: 1.42.0
Commit: ae08d5460b5a45169385ff3fd44208f431992451
Date: 2020-02-06T10:51:33.119Z
Electron: 6.1.6
Chrome: 76.0.3809.146
Node.js: 12.4.0
V8: 7.6.303.31-electron.0
OS: Darwin x64 19.3.0

Disable insertion by projects or subdirectory

How can I disable insertion or automatic update of include guards for a project?
And, on the other hand, if for a project I need to have it active in some directories but not in others, how can I do that?

README.md needs improvements

(Related to #17)

Current version of README.md needs some improvements:

  • Better descriptions of the usage of this extension.
  • Better descriptions of the lately added features.
  • Better overall structure.

I'm trying to find time to do that after releaseing v1.6.0.

Option to not have trailing #endif comment.

Hello,

Love the project! It'd be great to see an option to not have any trailing comment on the #endif line, as I do not like doing this in my code, and I'm sure others are in the same boat.

Thanks!

Auto Update does not work

Auto updating include guards when renaming a header does not work for me.

My settings, which deviate from default:

Include Guard: Macro Type โ†’ Filename
Remove Extension โ†’ disabled

If I call the update myself using the command palette, it works. It just doesn't do anything automatically, when I rename a header via F2 or context menu.

Restarting or reloading VSCode does not help.

Auto Update Include Guard breaks C/C++ rename

When the setting "Auto Update Include Guard" is enabled, and I try to rename a C++ variable using the C/C++ tools extension, and if:

  • the rename touches several files
  • The rename cannot automatically choose which occurrences to change, but rather gives me the "Refactor preview" menu from which I pick and choose the instances

the rename fails with the message Cannot apply refactoring because '<name of file from where I clicked on the variable>' has changed in the meantime.. This happens even when none of the include guards have actually changed. Interestingly, the file name does show the white blob telling its been modified, but if I save it, nothing has changed.

Auto-update tend to unintendedly update

Hi,

When it comes to automatically update the include guard I only see those two settings:

  • C/C++ Include Guard: Auto Include Guard Insertion For New File (automatically insert the include guard when adding a new header file)
  • C/C++ Include Guard: Auto Update Include Guard (automatically update the include guard when renaming a file)

Considering there description I would like them both activated (which is the default), but it appears that the include guards are automatically updated even when I don't rename a file -- usually when I goto-definition (for the record I use clangd extension).

This creates unintended changes when I work on other projects than mine.

I suspect the "Auto Update Include Guard" to be the culprit, considering its name instead of the description, so I'll de-activate it, but I'd really like to use an auto-update when renaming a file.

BUG: etime.h never included, with filename macro

My project has a file named etime.h. When the 'Macro Type' is set to 'Filename', this file is never included, because the auto-generated include guard is named ETIME.

The following code reproduces the bug:

main.cpp

#include <iostream>
#include "etime.h"

int main(){
    greet();
}

etime.h

#ifndef ETIME
#define ETIME

int greet(){
    std::cout << "hello" << std::endl;
}

#endif /* ETIME */

Expected behavior: If the filename begins with e, avoid the macro name beginning with E by a digit or an uppercase letter (say, by inserting _ after E).

I'm using Arch Linux and gcc (GCC) 13.2.1.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.