User forums > General (but related to Code::Blocks)

Console for testing purposes

(1/2) > >>

vicent:
Dear all,

Sorry if this question is too naive. Anyway, I hope I can get your help, and I also hope this will be useful to others.

I am used to the 'console' in Rstudio, for instance (also in Scilab, Matlab,...), meaning an interactive command-line interface in which you can execute commands or functions belonging to either system, user-defined or third-party libraries that have been previously included/loaded/defined/declared in the current session.

I find this sort of console very useful, since it allows the programmer to check whether the functions they coded behave as expected or not.

I know that C works differently, since programs need to be compiled before being called/used/recognised.

Anyway, how can I get a sort of 'console' where I can 'play' with the functions I am building or using, either in Code::Blocks or outside it? My OS is Windows 10.

Should I just open a DOS console and use my functions (previously compiled), or do I need to have something else into account?

I look forward to your answers.

---

EDIT:

In case it helps, the functions I am interested in testing are bundled in an 'h' header. After compiling my current project, I have an 'o' file for each of my libraries, but only an 'exe' file for the main routine, as expected.

I understand that I cannot 'play' with my functions without previously compiling them, can I?

jordi:
Hi,
Correct. You have to compile you main program and link with the libraries to create the executable.

Seeing Code::Blocks (I am a newbie too), I have known squirrel-lang.  The syntax is similar to C.
http://www.squirrel-lang.org/
It needs more knowledge, you might create your C/C++ libraries and use them with squirrel-lang through bindings.

cling could be an alternative but I don't know if there is binaries for windows
https://github.com/root-project/cling
Regards

BlueHazzard:
A "console" like you wish exist, like you noted, only in interpreted languages like python, lua, matlab ecc...
There are some jit compiler for c/c++ (for example https://blog.quarkslab.com/easyjit-just-in-time-compilation-for-c.html, or https://github.com/root-project/cling)
but this is not really related to codeblocks.... If you have some jit compiler you want to test, you can ask and we can look if we can implement something

vicent:

--- Quote from: jordi on December 10, 2021, 10:55:44 pm ---Hi,
Correct. You have to compile you main program and link with the libraries to create the executable.

Seeing Code::Blocks (I am a newbie too), I have known squirrel-lang.  The syntax is similar to C.
http://www.squirrel-lang.org/
It needs more knowledge, you might create your C/C++ libraries and use them with squirrel-lang through bindings.

cling could be an alternative but I don't know if there is binaries for windows
https://github.com/root-project/cling
Regards

--- End quote ---

Thank you, @jordi, but I chose C over R and Scilab ---which I have already worked with--- because it is faster and as reliable as them. Besides, I need to use the GNU Scientific Library (GSL) in my projects, and I am uncertain about whether this library is available for Squirrel.

BTW, I've programmed in C in the past, but it is now, after having tried Rstudio, that I am missing that console thing.

vicent:
Hi @BlueHazzard and all,

I was thinking (more) about my question...

Maybe it is just as simple as running a programme in debug mode and setting a breakpoint just after starting the `main` routine. In that very moment, can I access any sort of console in the debug mode, a console in which I can call the functions that have been included in the header and do calculations with them?

I look forward to your answer.

Navigation

[0] Message Index

[#] Next page

Go to full version