-exx closing the program without warning?

General FreeBASIC programming questions.
Post Reply
IvanisIvan
Posts: 44
Joined: Nov 07, 2019 21:57

-exx closing the program without warning?

Post by IvanisIvan »

G'day,
today I was messing about and wrote this piece of code:

Code: Select all

dim array(10) as integer = {1,6,3,7,2,6,7,9,2,1}
for i as integer = -1000 to 9 step 1
    print array(i)
next i
sleep
I expected it to immediately crash due to an out of bounds error, and to my shock, it didn't! I learnt about compiler commands so I assumed that -exx is the one I should add. Now, it does successfully cause the program to crash, but it leaves no error message. I have tried putting in -w all in the compiler command section, but it does not seem to help. :( Could someone please help me with this? Additionally, why is -exx not put on by default? This seems dangerous!

Code: Select all

command:"<$fbc>"  "<$file>" -exx -w all
run:"<$file>" <$param>
paul doe
Posts: 1862
Joined: Jul 25, 2017 17:22
Location: Argentina
Contact:

Re: -exx closing the program without warning?

Post by paul doe »

IvanisIvan wrote: Mar 17, 2022 1:45 ...
Could someone please help me with this?
...
To be able to see the error, you need to compile and execute the program from the command line. Otherwise a console window opens and closes immediately.
...
Additionally, why is -exx not put on by default? This seems dangerous!
...
Because it adds both run-time costs and bloats the executable. That's why most programming environments allow for a 'debug' build (with run-time checks and other features, usually selected via switches) and a 'release' build (with very little or no debug features enabled).
IvanisIvan
Posts: 44
Joined: Nov 07, 2019 21:57

Re: -exx closing the program without warning?

Post by IvanisIvan »

paul doe wrote: Mar 17, 2022 3:39
IvanisIvan wrote: Mar 17, 2022 1:45 ...
Could someone please help me with this?
...
To be able to see the error, you need to compile and execute the program from the command line. Otherwise a console window opens and closes immediately.
...
Additionally, why is -exx not put on by default? This seems dangerous!
...
Because it adds both run-time costs and bloats the executable. That's why most programming environments allow for a 'debug' build (with run-time checks and other features, usually selected via switches) and a 'release' build (with very little or no debug features enabled).
I see. Is there a way I can make the console window not close immediately?
fxm
Moderator
Posts: 12551
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: -exx closing the program without warning?

Post by fxm »

What IDE are you using ?
dodicat
Posts: 8243
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: -exx closing the program without warning?

Post by dodicat »

With fb 1.09 you no longer need to put compiler options in an ide, you can put them in code.
But that is optional of course.

Code: Select all

#cmdline "-exx"
dim array(10) as integer = {1,6,3,7,2,6,7,9,2,1}
for i as integer = -1000 to 9 step 1
    print array(i)
next i
sleep
In fbide here is the run command to keep the console open:
In the ide;
view->settings->freebasic, in the Run command box:

cmd /c "<$file>" <$param> & pause

I believe some other ides have an option for the run command.
Post Reply