vendredi 20 janvier 2023

Why does the IDE say that the function is supposedly not defined?

Can you tell me why the IDE indicates that the "func" function is not defined, although I have defined it below and the code is compiled without errors in principle? This happens only with the prototype of a function that returns a pointer to an array in this style. enter image description here

#include <iostream>

auto func(int value) -> int(*)[10]; // Function definition for "func" not found

int main()
{
  // some code

  return 0;
}

auto func(int value) -> int(*)[10]
{
  return nullptr;
}

There is no such indicator if you describe the prototype in the old style as int(*func(int value))[10]

also, everything is normal if you write like this:

#include <iostream>

using arr_ptr = int(*)[10];

auto func(int value) -> arr_ptr;

int main()
{
  // some code

  return 0;
}

auto func(int value) -> arr_ptr
{
  return nullptr;
}

I am writing a number in Visual Studio 2022. 20 standard is specified in the settings

The code compiles but I expect there won't be any error indicators...

Aucun commentaire:

Enregistrer un commentaire