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

ignore warnning on some functions #3588

Closed
david85fr opened this issue May 6, 2019 · 5 comments
Closed

ignore warnning on some functions #3588

david85fr opened this issue May 6, 2019 · 5 comments

Comments

@david85fr
Copy link

david85fr commented May 6, 2019

Type: LanguageService

vscode show this function as

#define max(a,b) \
       ({ __typeof__ (a) _a = (a); \
          __typeof__ (b) _b = (b); \
          _a > _b ? _a : _b; })

resMax = max( a , b );

vscode show warning, as expected an expression.
Can i disable warning on some define() ?

  • VS Code Version: 1.33.1
  • C/C++ Extension Version: 0.22.1
@bobbrow
Copy link
Member

bobbrow commented May 6, 2019

Thank you for your issue report. Which compiler and flags are you using to compile this? We may consider repurposing this issue to track support for the syntax that you have shared.

We have a feature request open to disable certain errors. #2345

@HoriKyouko
Copy link

HoriKyouko commented Jul 8, 2019

I'm getting a similar issue when creating my own max function the intellisense is saying there is an error with the declaration of my max function (seen below are the function and error):

int max(int num1, int num2){
return (num1 > num2) ? num1 : num2;
}

should "expected an identifier" then says:
"#define max(a,b) (((a) > (b)) ? (a) : (b))
Expands to:
(((int num1) > (int num2)) ? (int num1) : (int num2))"

Screenshot of VSCode showing above error on function and the problems it's detecting:
Screenshot (2)
The semicolon error occurs right after the "int max(int num1, int num2)" saying that it should be right after the ')'

When I compile with "gcc -Wall -Werror..." no warnings/errors pop up in the terminal and when I run my executable everything runs fine:
Screenshot (3)

@sean-mcmanus
Copy link
Collaborator

@HoriKyouko It seems to be picking up a max macro from some other location. Did you set your compilerPath to your gcc compiler? It might be picking up a VC++ header instead.

@bobbrow
Copy link
Member

bobbrow commented Apr 2, 2020

The code in the original example looks to be invalid syntax. I couldn't find a compiler on godbolt.org that successfully compiles it.

@bobbrow bobbrow closed this as completed Apr 2, 2020
@bobbrow
Copy link
Member

bobbrow commented Apr 2, 2020

And the original request to ignore errors for specific functions may be covered by #2395

@github-actions github-actions bot locked and limited conversation to collaborators Oct 10, 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