Witaj na Forum Linuxiarzy
Zanim zalogujesz się, by pisać na naszym forum, zapoznaj się z kilkoma zasadami savoir-vivre'u w dziale Administracja.
Wiadomości z problemami zamieszczone w wątku "Przywitaj się" oraz wszelkie reklamy na naszym forum będą usuwane.

Clangd w VSCode podkreśla na czerwono

Zaczęty przez grzesio31, Czerwiec 14, 2025, 05:14:30 PM

Poprzedni wątek - Następny wątek

grzesio31

Cześć, może ktoś będzie wiedział jak usunąć te czerwone komunikaty z rozszerzenia clangd?
Chodzi o edytory klony VSCode, ponieważ od niedawna Microsoft już nie wspiera rozszerzenia C/C++ w tych że edytorach.
Wyskakuje taki komunikat gdy najeżdżam myszą.
Use of undeclared identifier 'println'clang(undeclared_var_use)
Mam na czerwono podkreślone te println(); ze standardu C++23.
Mogę dodać taki wpis w settings.json ale nie o to mi chodzi.

"workbench.colorCustomizations": {
        "editorError.foreground": "#00000000",
        "editorWarning.foreground": "#00000000",
        "editorInfo.foreground": "#00000000"
    },
// TIC TAC TOE game
#include <iostream>
#include <print>
using namespace std;

void drawBoard(char *spaces);
void playerMove(char *spaces, char player);
void computerMove(char *spaces, char computer);
bool checkWinner(char *spaces, char player, char computer);
bool checkTie(char *spaces);

int main() {

  char spaces[9] = {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '};
  char player = 'X';
  char computer = 'O';
  bool running = true;

  drawBoard(spaces);

  while (running) {
    playerMove(spaces, player);
    drawBoard(spaces);
    if (checkWinner(spaces, player, computer)) {
      running = false;
      break;
    } else if (checkTie(spaces)) {
      running = false;
      break;
    }

    computerMove(spaces, computer);
    drawBoard(spaces);
    if (checkWinner(spaces, player, computer)) {
      running = false;
      break;
    } else if (checkTie(spaces)) {
      running = false;
      break;
    }
  }
  println("Thanks for playing!");

  return 0;
}

void drawBoard(char *spaces) {
  println();
  println("     |     |     ");
  println("  {}  |  {}  | {}", spaces[0], spaces[1], spaces[2]);
  println("_____|_____|_____");
  println("     |     |     ");
  println("  {}  |  {}  | {}", spaces[3], spaces[4], spaces[5]);
  println("_____|_____|_____");
  println("     |     |     ");
  println("  {}  |  {}  | {}", spaces[6], spaces[7], spaces[8]);
  println("     |     |     ");
  println();
}
void playerMove(char *spaces, char player) {
  int number;
  do {
    print("Enter a spot to place a marker (1-9): ");
    cin >> number;
    number--;
    if (spaces[number] == ' ') {
      spaces[number] = player;
      break;
    }
  } while (!number > 0 || !number < 8);
}
void computerMove(char *spaces, char computer) {
  int number;
  srand(time(0));

  while (true) {
    number = rand() % 9;
    if (spaces[number] == ' ') {
      spaces[number] = computer;
      break;
    }
  }
}
bool checkWinner(char *spaces, char player, char computer) {

  if ((spaces[0] != ' ') && (spaces[0] == spaces[1]) &&
      (spaces[1] == spaces[2])) {
    //  spaces[0] == player ? println("YOU WIN!" ) : println("YOU LOSE!");
    println("{}", (spaces[0] == player ? "YOU WIN!" : "YOU LOSE!"));
  } else if ((spaces[3] != ' ') && (spaces[3] == spaces[4]) &&
             (spaces[4] == spaces[5])) {
    println("{}", (spaces[3] == player ? "YOU WIN!" : "YOU LOSE!"));
  } else if ((spaces[6] != ' ') && (spaces[6] == spaces[7]) &&
             (spaces[7] == spaces[8])) {
    println("{}", (spaces[6] == player ? "YOU WIN!" : "YOU LOSE!"));
  } else if ((spaces[0] != ' ') && (spaces[0] == spaces[3]) &&
             (spaces[3] == spaces[6])) {
    println("{}", (spaces[0] == player ? "YOU WIN!" : "YOU LOSE!"));
  } else if ((spaces[1] != ' ') && (spaces[1] == spaces[4]) &&
             (spaces[4] == spaces[7])) {
    println("{}", (spaces[1] == player ? "YOU WIN!" : "YOU LOSE!"));
  } else if ((spaces[2] != ' ') && (spaces[2] == spaces[5]) &&
             (spaces[5] == spaces[8])) {
    println("{}", (spaces[2] == player ? "YOU WIN!" : "YOU LOSE!"));
  } else if ((spaces[0] != ' ') && (spaces[0] == spaces[4]) &&
             (spaces[4] == spaces[8])) {
    println("{}", (spaces[0] == player ? "YOU WIN!" : "YOU LOSE!"));
  } else if ((spaces[2] != ' ') && (spaces[2] == spaces[4]) &&
             (spaces[4] == spaces[6])) {
    println("{}", (spaces[2] == player ? "YOU WIN!" : "YOU LOSE!"));
  } else {
    return false;
  }

  return true;
}
bool checkTie(char *spaces) {

  for (int i = 0; i < 9; i++) {
    if (spaces[i] == ' ') {
      return false;
    }
  }
  println("IT'S A TIE!");
  return true;
}

Zobacz najnowsze wiadomości na forum