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

AVR Assembler Errors (i.e. Arduino) #2377

Closed
vicatcu opened this issue Aug 9, 2018 · 3 comments
Closed

AVR Assembler Errors (i.e. Arduino) #2377

vicatcu opened this issue Aug 9, 2018 · 3 comments

Comments

@vicatcu
Copy link

vicatcu commented Aug 9, 2018

Type: LanguageService
----- Input information below -----

Please review existing issues and our documentation at https://github.com/Microsoft/vscode-cpptools/tree/master/Documentation prior to filing an issue.

Describe the bug

  • OS and Version: Ubuntu 18.04
  • VS Code Version: 1.25.1 (x64)
  • C/C++ Extension Version: 0.17.7
  • Other extensions you installed (and if the issue persists after disabling them):
    vsciot-vscode.vscode-arduino, rockcat.avr-support
  • A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:
Provide a code sample including configuration files such as c_cpp_properties.json

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
Using common macros from Arduino (i.e. digitalPinToBitMask, digitalPinToPort, portOutputRegister) they get flagged as errors in the Problems tab with the message "unknown register name 'r0'". The following is my c_cpp_properties.json contents at this time.

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**",
                "/home/vic/arduino-1.8.5/hardware/arduino/avr/cores/arduino",
                "/home/vic/arduino-1.8.5/hardware/arduino/avr/variants/standard",
                "/home/vic/arduino-1.8.5/hardware/tools/avr/avr/include"
            ],
            "defines": [
              "F_CPU=16000000",
              "ARDUINO",
              "ARDUINO_ARCH_AVR",
              "__AVR_ATmega328P__"
            ],
            "compilerPath": "/home/vic/arduino-1.8.5/hardware/tools/avr/bin/avr-gcc",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "clang-x64"
        }
    ],
    "version": 4
}

Screenshots
N/A

Additional context
N/A

@sean-mcmanus
Copy link
Contributor

Our IntelliSense parser doesn't have any special-case code for "Arduino compiler" mode, just clang/gcc/cl.exe modes -- I don't know if we'll be able to get the compiler to support non-standard features specific to Arduino.

@conklech
Copy link

The Arduino functions call platform-specific macros. AVR-GCC needs to be given the correct platform identifier, e.g. -mmcu=atmega2560, on the command line, in order to know what registers are available. See GCC docs here.

This can be supported in vscode-tools by adding the correct option to the "compilerPath" string. For the original reporter, the correct entry is likely:

"compilerPath": "/home/vic/arduino-1.8.5/hardware/tools/avr/bin/avr-gcc -mmcu= atmega328p"

In short: not a vscode-cpptools bug, but it's pretty difficult for an end-user to determine what's wrong. It could conceivably be appropriate to document this here. When c_cpp_properties.json is automatically generated, it would be nice if the generator tools got this right.

@Colengms
Copy link
Contributor

I know this is a rather old issue, but this doesn't sound like a bug to me, per se. We can't assume that the user does not want to use the default mode of the compiler that was specified. We cannot know if the '-mmcu' arg is needed, or what the user would like it to be set to. It needs to be specified by the user (or tool that generates c_cpp_properties.json), in either the compilerPath, the compilerArgs, or on a command line in compile_commands.json, etc.. We will then use that arg when probing the compiler (if a gcc/clang variant), to solicit the proper set of system defines and system includes from the compiler. As such, I think this issue is by-design. Please let me know if there is something I've misunderstood. Should this instead be filed against a tool that is generating your c_cpp_properties.json ?

@github-actions github-actions bot locked and limited conversation to collaborators Dec 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants