[solved] C code support and 2D array

Hello,

I have a 2D array char g[height][width] in my main().
And i want to call void affect(int height, int width, char g[height][width])
When I write affect(height, width, g);, the code support tells me :

No matching function for call to ‘affect’

main.c:173:9: note: candidate function not viable: no known conversion from ‘char [height][width]’ to ‘char (*)[width]’ for 3rd argument

I am not an expert, so maybe there’s something wrong that I don’t see ?
Thanks for your help !

What you describe is exactly the following, which does not raise any compilation error.

void affect(int height, int width, char g[height][width]) {}

int main() {
  int height, width;
  char g[height][width];
  affect(height, width, g);
  return 0;
}

Ok thanks, that’s what I thought.
So I guess I should just ignore the warning message

The issue is that there is a syntax error in the ide, even though it’s not actually an error

Oh ok, it’s an error of the new CG IDE (that’s what you meant by “code support”)…

image

1 Like

Thank you both

Hello,

clangd was updated some weeks ago, and it seems this issue was fixed in the new version.

Thanks for reporting it!

1 Like