compilation program

I get an error occured during compilation program.

What is happening?

1 Answer



0



There are two major classifications of errors in GAUSS. The first is compile-time errors and the second is run-time errors.

Compile time is when the text in your program is turned into code that the computer can understand. A compile time error means that GAUSS could not turn the text in your program into a legal GAUSS program. Let's look at some simple examples. Here is a working version of a very simple program:

x = rndn(3, 1);
x_last = x[3];

In the above program, we simply create a 3x1 vector x filled with random normal numbers and then we create a new variable x_last which we assign to be equal to the third value of x.

Now we will show a few versions of this program that will cause compile-time errors.

x = rndn[3, 1);
x_last = x[3];

Above we changed the parenthesis immediately after rndn to be a square bracket. Since rndn[3, 1); is not a legal GAUSS statement, GAUSS cannot take this text and turn it into anything that the computer can run. It will therefore cause a compile-time error.

x = rndn(3, 1)
x_last = x[3];

In this example, the semi-colon was left off of the first line. GAUSS uses semi-colons to separate statements. So, leaving off this semi-colon tells GAUSS that both lines are one statement, like this:

x = rndn(3, 1) x_last = x[3];

GAUSS cannot make sense of that line above as one statement, which is why it will create a compile-time error.

Some of the most common causes of compile-time errors are:

  1. No semi-colon at the end of the line
  2. Misspelled function or variable names
  3. Missing or unclosed parentheses

Most of the time, GAUSS will return an error containing the line number on which you have an error. You will see something like this in the error window:

Line 10 in C:\gauss13\myprogram.gss
    Syntax error G0008: '10 }'

If you double-click on the first line in the error window, GAUSS will take you to the line and file where it is reporting the error. Much of the time you will find a typo on this line.

However, sometimes a problem on one line will not make the program illegal until a few lines later. So if the line on which the error is reported seems OK, look at the lines above for a problem.

If you cannot locate the problem by inspection, it often helps to run a chunk of your code at a time. You can highlight a block of code with your mouse and run just the selected text by hitting F4 or by right-clicking and selecting "run selected text" from the context menu. By starting at the top of your program and highlighting chunks of your code, you will be able to better locate the line that is causing the error

The GAUSS debugger is a very valuable tool for diagnosing run-time problems in your code, however, you cannot run a program with a compile time error through the debugger since the debugger needs to compile your code (turn the text into something the computer can run).

aptech

1,773

Your Answer

1 Answer

0

There are two major classifications of errors in GAUSS. The first is compile-time errors and the second is run-time errors.

Compile time is when the text in your program is turned into code that the computer can understand. A compile time error means that GAUSS could not turn the text in your program into a legal GAUSS program. Let's look at some simple examples. Here is a working version of a very simple program:

x = rndn(3, 1);
x_last = x[3];

In the above program, we simply create a 3x1 vector x filled with random normal numbers and then we create a new variable x_last which we assign to be equal to the third value of x.

Now we will show a few versions of this program that will cause compile-time errors.

x = rndn[3, 1);
x_last = x[3];

Above we changed the parenthesis immediately after rndn to be a square bracket. Since rndn[3, 1); is not a legal GAUSS statement, GAUSS cannot take this text and turn it into anything that the computer can run. It will therefore cause a compile-time error.

x = rndn(3, 1)
x_last = x[3];

In this example, the semi-colon was left off of the first line. GAUSS uses semi-colons to separate statements. So, leaving off this semi-colon tells GAUSS that both lines are one statement, like this:

x = rndn(3, 1) x_last = x[3];

GAUSS cannot make sense of that line above as one statement, which is why it will create a compile-time error.

Some of the most common causes of compile-time errors are:

  1. No semi-colon at the end of the line
  2. Misspelled function or variable names
  3. Missing or unclosed parentheses

Most of the time, GAUSS will return an error containing the line number on which you have an error. You will see something like this in the error window:

Line 10 in C:\gauss13\myprogram.gss
    Syntax error G0008: '10 }'

If you double-click on the first line in the error window, GAUSS will take you to the line and file where it is reporting the error. Much of the time you will find a typo on this line.

However, sometimes a problem on one line will not make the program illegal until a few lines later. So if the line on which the error is reported seems OK, look at the lines above for a problem.

If you cannot locate the problem by inspection, it often helps to run a chunk of your code at a time. You can highlight a block of code with your mouse and run just the selected text by hitting F4 or by right-clicking and selecting "run selected text" from the context menu. By starting at the top of your program and highlighting chunks of your code, you will be able to better locate the line that is causing the error

The GAUSS debugger is a very valuable tool for diagnosing run-time problems in your code, however, you cannot run a program with a compile time error through the debugger since the debugger needs to compile your code (turn the text into something the computer can run).


You must login to post answers.

Have a Specific Question?

Get a real answer from a real person

Need Support?

Get help from our friendly experts.