-1

My VS Code's C/C++ extension can crawl errors inside my main() function, but not in my template function.

Showing the problem highlighting here in my main function:
screenshot of main function with problem highlighting

But not here in my template function definition where I created the same problem of assigning a string literal to an int:
screenshot of template function with no problem highlighting

Why does this happen?

I tried to search Extension settings but found nothing (I may have skipped something).

starball
  • 20,030
  • 7
  • 43
  • 238
  • The problem may be caused because you use a template for `Node`. Check if the errors in a function or a class without template are underlined. – Ivan Venkov Jan 23 '23 at 12:43
  • Welcome! Can you please read about [the problems with images of text](//meta.stackoverflow.com/a/285557/11107541) and then [edit] to **add transcriptions** of your images of text as actual text? Perhaps useful: [/help/formatting](/help/formatting). – starball Jan 23 '23 at 20:59

1 Answers1

0

The problem highlighting in the VS Code editor is based on compiler warnings. Compilers are not required to emit diagnostics for problems that occur in uninstantiated templates. You haven't provided enough info to know whether you have instantiated that template anywhere, but I'll bet you haven't. Instaniate it somewhere by calling it in a non-template function or another instantiated template function, or explicitly instantiate it.

See also this Q&A: error in unused template method.

starball
  • 20,030
  • 7
  • 43
  • 238