Geany ошибка 9009 паскаль

I think you missed to compile your code. Geany is an editor with functions of an IDE, but for using C++ with Geany you will need to follow these steps:

  1. Install a C++-compiler on your Widnows
  2. Hack your code and save it e.g. as test.cpp
  3. Ensure Geany knows about your C++ compiler by checking/changing settings via Build->Set Build Commands
  4. Compile your code/build your code by e.g. hitting F9
  5. Start your program

I assume you missed at least point 4.

answered Nov 27, 2016 at 13:21

frlan's user avatar

frlanfrlan

6,9603 gold badges32 silver badges72 bronze badges

Я новичок в мире программирования, когда я набрал свой код в Geany и выполнил его, он выдает ошибку, как на этом рисунке.

2016-11-26 17:05

1
ответ

Я думаю, что вы пропустили компилировать свой код. Geany — это редактор с функциями IDE, но для использования C++ с Geany вам необходимо выполнить следующие шаги:

  1. Установите C++- компилятор на свои Widnows
  2. Взломайте ваш код и сохраните его, например, как test.cpp
  3. Убедитесь, что Geany знает о вашем компиляторе C++, проверив / изменив настройки через Build->Set Build Commands
  4. Скомпилируйте ваш код / ​​создайте его, например, нажав F9
  5. Начните свою программу

Я полагаю, вы пропустили хотя бы пункт 4.

2016-11-27 13:21

Yesterday I wrote a simple python program using Geany and it worked just right, today when I went to write another program, I received error 9009 and the editor didn’t highlight any words, they were all colored as variables (e.g print, while, int, input and …).

I did a bit of research and ultimately fixed error 9009 and managed to run my program but Geany still doesn’t highlight my code, and when I execute my other programs they’re all also non-highlighted and give me error code 2.

To fix the error 9009 I changed the Execute command in Set Build Commands to Python %f and it worked, I tried deleting and reinstalling Geany for the greyed out text, but it didn’t work.

Any ideas?

Greyed out codes:
Greyed out codes

Error code 2 for programs before this happened:
Error code 2 for programs before this happened

Case statements are only labels. This means the compiler will interpret this as a jump directly to the label. In C++, the problem here is one of scope. Your curly brackets define the scope as everything inside the switch statement. This means that you are left with a scope where a jump will be performed further into the code skipping the initialization.

The correct way to handle this is to define a scope specific to that case statement and define your variable within it:

switch (val)
{   
case VAL:  
{
  // This will work
  int newVal = 42;  
  break;
}
case ANOTHER_VAL:  
...
break;
}

The do ... while and if ... else are there to make it so that a
semicolon after your macro always means the same thing. Let’s say you
had something like your second macro.

#define BAR(X) f(x); g(x)

Now if you were to use BAR(X); in an if ... else statement, where the bodies of the if statement were not wrapped in curly brackets, you’d get a bad surprise.

if (corge)
  BAR(corge);
else
  gralt();

The above code would expand into

if (corge)
  f(corge); g(corge);
else
  gralt();

which is syntactically incorrect, as the else is no longer associated with the if. It doesn’t help to wrap things in curly braces within the macro, because a semicolon after the braces is syntactically incorrect.

if (corge)
  {f(corge); g(corge);};
else
  gralt();

There are two ways of fixing the problem. The first is to use a comma to sequence statements within the macro without robbing it of its ability to act like an expression.

#define BAR(X) f(X), g(X)

The above version of bar BAR expands the above code into what follows, which is syntactically correct.

if (corge)
  f(corge), g(corge);
else
  gralt();

This doesn’t work if instead of f(X) you have a more complicated body of code that needs to go in its own block, say for example to declare local variables. In the most general case the solution is to use something like do ... while to cause the macro to be a single statement that takes a semicolon without confusion.

#define BAR(X) do { \
  int i = f(X); \
  if (i > 4) g(i); \
} while (0)

You don’t have to use do ... while, you could cook up something with if ... else as well, although when if ... else expands inside of an if ... else it leads to a «dangling else», which could make an existing dangling else problem even harder to find, as in the following code.

if (corge)
  if (1) { f(corge); g(corge); } else;
else
  gralt();

The point is to use up the semicolon in contexts where a dangling semicolon is erroneous. Of course, it could (and probably should) be argued at this point that it would be better to declare BAR as an actual function, not a macro.

In summary, the do ... while is there to work around the shortcomings of the C preprocessor. When those C style guides tell you to lay off the C preprocessor, this is the kind of thing they’re worried about.

Понравилась статья? Поделить с друзьями:
  • Gea чиллер коды ошибок
  • Gdiplus dll как исправить ошибку
  • Gdmss plus ошибка подключения что делать
  • Garry s mod ошибки текстур
  • Gascap крайслер ошибка