Skip to content
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.

#define cli() __asm__ __volatile__ ("cli" ::: "memory") #1165

Closed
fredOnGitHub opened this issue Dec 25, 2020 · 5 comments
Closed

#define cli() __asm__ __volatile__ ("cli" ::: "memory") #1165

fredOnGitHub opened this issue Dec 25, 2020 · 5 comments

Comments

@fredOnGitHub
Copy link

fredOnGitHub commented Dec 25, 2020

Hello, I have a problem to recognize interruptions with UNO Rev 3

I get

bug

#define cli() __asm__ __volatile__ ("cli" ::: "memory")
Se développe sur :

__asm__ __volatile__ ("cli" ::: "memory")
identificateur "__asm__" non définiC/C++(20)
Peek Problem (Alt+F8)
No quick fixes available

My JSON is

...
 "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE",
                "__AVR_ATmega328P__",
                "USBCON"
            ],
...

Note : Ok for Serial with the adding of "USBCON" but for
cli()
TCCR2A
?

Thanks for your help

@fredOnGitHub
Copy link
Author

fredOnGitHub commented Dec 31, 2020

Now my project is like :

  • all my files are .ino,
  • the main .ino contains all STRUCT and variables,
  • others .ino are only for functions (like classes).

All is OK for compilation but I can read underline under :

  • function name that are in other .ino file,
  • cli() ;//stop interrupts,
  • TCCR2A,
  • etc.

@adiazulay
Copy link
Contributor

I think #1141 should resolve this

@fredOnGitHub
Copy link
Author

fredOnGitHub commented Jan 10, 2021

Hello,

i have reinstalled vs code plugin from vs code but it the problem still get.

I don't know how to use #1141

@itopaloglu83
Copy link

Majority of the library configuration is done via the help of preprocessor macros. These macros depend on certain directives to be provided at compile time. For example microcontroller name __AVR_ATmega328P__

These directives are later used in the library to either turn on or off certain functionalities. And that's exactly where your code is failing. Avr-gcc has an extensive list of command line arguments that it later converts to macro definitions. You may see the full list at the address below.

https://www.nongnu.org/avr-libc/user-manual/using_tools.html

In your case including the chip type in c_cpp_properties.json should resolve all the issues. Here's an example from a project I have. All you need to do is to add the __AVR_ATmega328P__ to the defines array.

{
    "configurations": [
        {
            "name": "Mac",
            "includePath": [
                "/Applications/Arduino.app/Contents/Java/tools/**",
                "/Users/<your_username_here>/Downloads/Developer/Arduino/Sketches/libraries/**",
                "/Applications/Arduino.app/Contents/Java/libraries/**",
                "/Applications/Arduino.app/Contents/Java/hardware/tools/**",
                "/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/**"
            ],
            "forcedInclude": [
                "/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino/Arduino.h"
            ],
            "defines": [
                "USBCON",
                "__AVR_ATmega328P__"
            ],
            "macFrameworkPath": [
                "/System/Library/Frameworks",
                "/Library/Frameworks"
            ],
            "intelliSenseMode": "macos-clang-x64",
            "compilerPath": "/usr/bin/clang",
            "cStandard": "c11",
            "cppStandard": "c++98"
        }
    ],
    "version": 4
}

You may find more information here #438 (comment) about why it happens.

@adiazulay
Copy link
Contributor

IntelliSense auto-generation has been added in v0.4.0. If you're having any problems with IntelliSense please open a new issue.

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

3 participants