Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clang-format command wrong syntax #12819

Closed
prototact opened this issue Oct 8, 2024 · 3 comments
Closed

Clang-format command wrong syntax #12819

prototact opened this issue Oct 8, 2024 · 3 comments
Assignees
Labels
bug Feature: Code Formatting fixed Check the Milestone for the release in which the fix is or will be available. Language Service quick fix
Milestone

Comments

@prototact
Copy link

prototact commented Oct 8, 2024

Environment

  • OS and Version: Linux x64 6.10.12-200.fc40.x86_64
  • VS Code Version: 1.94.0
  • C/C++ Extension Version: 1.22.7 (pre-release)
  • If using SSH remote, specify OS of remote machine: Ubuntu 22.04

Bug Summary and Steps to Reproduce

Bug Summary:
The command options to clang-format have bad syntax (one hyphen instead of two) when run by vscode on each save.

Steps to reproduce:

  1. Save file with clang-format
  2. Output is
    Formatting failed: clang-format -style=file:/{path}/.clang-format -fallback-style=LLVM --Wno-error=unknown -assume-filename={filepath} {filepath}

Expected behavior:
Normally the file would be formatted

Configuration and Logs

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${default}",
                "../build/**",
                "../src/**"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/clang",
            "cStandard": "c17",
            "intelliSenseMode": "linux-clang-x64"
        }
    ],
    "version": 4
}

-------- Diagnostics - 10/8/2024, 1:07:17 PM
Version: 1.22.7
Current Configuration:
{
    "name": "Linux",
    "includePath": [
        "/home/ns3/ns-3-dev/**"
    ],
    "defines": [],
    "compilerPath": "/usr/bin/clang",
    "cStandard": "c17",
    "intelliSenseMode": "linux-clang-x64",
    "compilerPathInCppPropertiesJson": "/usr/bin/clang",
    "cppStandard": "c++20",
    "intelliSenseModeIsExplicit": false,
    "cStandardIsExplicit": false,
    "cppStandardIsExplicit": true,
    "mergeConfigurations": false,
    "compilerPathIsExplicit": false,
    "browse": {
        "path": [
            "/home/ns3/ns-3-dev/**",
            "${workspaceFolder}"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
Modified Settings:
{
    "C_Cpp.default.cppStandard": "c++20",
    "C_Cpp.clang_format_path": "clang-format",
    "C_Cpp.clang_format_style": "file:/home/ns3/ns-3-dev/.clang-format",
    "C_Cpp.formatting": "clangFormat",
    "C_Cpp.clang_format_fallbackStyle": "",
    "C_Cpp.codeAnalysis.clangTidy.enabled": true,
    "C_Cpp.codeAnalysis.clangTidy.config": "/home/ns3/ns-3-dev/.clang-tidy /home/ns3/ns-3-dev/contrib/nr/.clang-tidy",
    "C_Cpp.updateChannel": "Insiders"
}
Additional Tracked Settings:
{
    "editorTabSize": 4,
    "editorInsertSpaces": true,
    "editorAutoClosingBrackets": "languageDefined",
    "filesEncoding": "utf8",
    "filesAssociations": {},
    "filesExclude": {
        "**/.git": true,
        "**/.svn": true,
        "**/.hg": true,
        "**/CVS": true,
        "**/.DS_Store": true,
        "**/Thumbs.db": true
    },
    "filesAutoSaveAfterDelay": false,
    "editorInlayHintsEnabled": true,
    "editorParameterHintsEnabled": true,
    "searchExclude": {
        "**/node_modules": true,
        "**/bower_components": true,
        "**/*.code-search": true
    },
    "workbenchSettingsEditor": "ui"
}
cpptools version (native): 1.22.7.0
Current database path: /home/ns3/.cache/vscode-cpptools/08916d960f07b7c21f876f6c779639b5/.browse.VC.db
rk/CMakeFiles/libnetwork-obj.dir/helper
...
    System Includes:
        /usr/include/c++/11
        /usr/include/x86_64-linux-gnu/c++/11
        /usr/include/c++/11/backward
        /usr/lib/llvm-14/lib/clang/14.0.0/include
        /usr/local/include
        /usr/include/x86_64-linux-gnu
        /usr/include
    Standard Version: c++20
    IntelliSense Mode: linux-clang-x64
    Other Flags:
        --clang
        --clang_version=140000
Total Memory Usage: 741 MB

------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 36794
Number of files parsed: 8378

Other Extensions

No response

Additional context

No response

@sean-mcmanus
Copy link
Contributor

sean-mcmanus commented Oct 8, 2024

@prototact What version of clang-format are you using? That single - version is supposed to work, although I'm not sure why we're not using the -- version.

Does running that command line with -- args fix it for you?

Is there any other additional info after the format fail message? It might be failing for a different reason, such as an invalid .clang-format.

@bobbrow bobbrow modified the milestones: 1.22, 1.23 Oct 8, 2024
@sean-mcmanus sean-mcmanus modified the milestones: 1.23, 1.23.0 Oct 8, 2024
@sean-mcmanus sean-mcmanus moved this from In progress to Pull Request in cpptools Oct 9, 2024
@sean-mcmanus sean-mcmanus moved this from Pull Request to Done in cpptools Oct 9, 2024
@sean-mcmanus sean-mcmanus added the fixed Check the Milestone for the release in which the fix is or will be available. label Oct 9, 2024
@prototact
Copy link
Author

The clang format file is fine, it is provided by a well-established software suite. If I use the -- it works yes.
Originally, I used Ubuntu clang-format version 14.0.0-1ubuntu1.1 but switched to a new container with Ubuntu clang-format version 18.1.3 (1ubuntu1).
Afterwards, another error appeared about a child process not working, which I googled and found a solution here, provided by you. So now everything is fine. Thank you for the help.

@sean-mcmanus
Copy link
Contributor

@github-actions github-actions bot locked and limited conversation to collaborators Nov 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Feature: Code Formatting fixed Check the Milestone for the release in which the fix is or will be available. Language Service quick fix
Projects
Status: Done
Development

No branches or pull requests

3 participants