The explanatory language does not need to be compiled, and modification is a great advantage.
C language can be regarded as my native language in computer language (although I have learned pascal, but unfortunately I have never programming ...), Today, I saw a c interpreter. After loading the interpreter, I found that the IDE would not be configured. It is okay to run the command below, and even c ++ and STL are supported, which is quite good.
UnderC
ACMer can try crab
Attached parameter descriptions under the command line
Command Summary
When UCW loads you will be presented with the;> prompt. You can now type a valid C ++ statement, a preprocessor directive like# Include, Or one of several extra interactive commands which all begin '#'. the Windows version allows you to mark output by dragging the mouse, and then ctrl-C or right-click will copy to the clipboard. it's also possible to use ctrl-V to paste commands into the prompt.
Alternatively, if using Windows, you can download the version of Quincy 2000, which will do these commands for you.
Quit Command: # q, # ql
Close session;# QLIn addition writes a unique log file, with
Name based on the time and date.
Load Command: # l
The most important command is# L fileWhich has the same effect
As# Include "file", Could t that the system does some clean-ups if
That module has been previusly loaded. It will remove any macros
That were defined in that source file, clean out typedefs, and
Remove any injected namespaces. So even if the std namespace is
Loaded in your interactive session (and this is the default) this
Doesn' t apply to any# L'D files.
After the first load,# LOn its own will reload the last file.
Run Program: # r
After a file containing a main () function is loaded, and successfully
Compiled,# RWill let you run that program with the supplied
Arguments. In UnderC for Windows, the program is run in its own thread and console window, so you can interactively evaluate variables etc while the program is waiting for input.
Execute shell command: # x
For example,# X dirOr# X LS-, Depending on your religion.
Load Library command: # lib , # Unload
After this command, any prototype or class definition is assumed
To be a request for dynamically linking to the library. This continues until# LibCommand without any file is found.
It is easy to import any extern "C" function from a DLL. For example,
All Windows systems have the Microsoft C runtime DLL, MSVCRT40.DLL. To make isalpha () available, one can say:
;># Lib msvcrt40.dll
;>Extern "C" int isalpha (char );
;>Isalpha ('*');
(Int) 0
;># Lib
It's important to finish off with a closing# Lib, Since UC will try to importAnyC ++ prototype from the current library until then. Please note that# LibOn its own does not unload the library; it merely signals the end of a special mode where prototypes are treated differently.
And in Linux, the equivalent is the standard C Runtime Shared Library:
;># Lib libc. so.6
;>Extern "C" int isalpha (char );
;>Isalpha ('*');
(INT) 0
;># Lib
You can of course use your own DLLs (they must be extern "C" exports) But remember in Linux to set the LD_LIBRARY_PATH appropriately.# UnloadCommand will release a DLL, so you can rebuilt it without leaving underc. The functions then have to be reloaded as abve, so it's useful to put this stuff in header files.
The# LibFeature will probably change somewhat; a c purist wowould prefer a UC-specific# Pragma, Rather than a new command.
You can now say# Pragma dlink libc. so.6In the above example, (and just# Pragma dlinkTo finish). The advantage of using a pragma is that C ++ compilers will not complain about special pragmas,# LibIs still supported.
There is a special form,# Lib $ caller, Which can be used by the uc dll/shared library to link to any functions exported by the main program itself.
Setting and Getting the Current Directory: # cd, # pwd
These commands can be used to set and display the current working directory.
Set Options: # opt
These are single-character options with either a' + 'or a'-'Following them. For instance,# Opt u +Switches on automatic dissembling of the generated pcode, and# Opt u-Switches this off. The following options are all off by default, but can be useful in debugging.
T-trace function call stack on crash
V-'verbose '-if trace is set, will trace ALL function CILS.
4-align to the nearest four-byte in structures
Setting Breakpoints: # B, # gt, # bs, # ff
There are also commands for setting breakpoints, etc, which are chiefly intended for use of any IDE.# BLine file will set a breakpoint at that point;# GtWorks the same way, but is used just to 'go to 'a particle line. The file must be loaded for these commands to have effect.
If the file is recompiled, then the breakpoints can get out of sync.# BsCommand is passed a filename, and a list of line numbers, which are interpreted as the new line numbers for each breakpoint.
When a program has halted, then# R(Without any parameters) will continue program execution.
# FfIs useful when you are halted at a breakpoint; you can switch to various function frames interactively (works rather like the GDB equivalent; this is still a new feature so it sometimes interferes with program resumption)
Inspecting and Displaying Variables: # lv, # d, # v, # rm
# LvWill display the current set of local variables.# DWill display the specified structure. For example:
;>String s = "hello dolly ";
;># D s
(Unsigned int) m_len = 11
(Char *) m_str = "hello dolly"
;>
# VWill give information about the specified function or variable. For example, this shows all members of an overloaded operator.
;># V operator
VAR ostream & substr (ostream &, int) <size 4 offset 9297344
1 ostream & operator <(ostream &, int)
2 ostream & operator <(ostream &, unsigned long int)
3 ostream & operator <(ostream &, bool)
4 ostream & operator <(ostream &, double)
5 ostream & operator <(ostream &, float)
6 ostream & operator <(ostream &, const char *)
7 ostream & operator <(ostream &, _ Endl _&)
8 ostream & operator <(ostream &, void *)
9 ostream & operator <(ostream &, char)
10 ostream & operator <(ostream &, const string &)
;>
# Rm xRemoves the symbol x. Normally UnderC does not regard redeclaration to be an error. If you redeclare an array, it will not be moved or reallocated if it was the same size as the last declaration.
Preprocessor Extensions
There are currently only two# PragmasAvailable for UnderC.
# Pragma dlink
This has exactly the same function# Lib, Bytes t that it is more C ++ friendly (other compilers will ignore it). Default alignment in structures can be switched between none, 4-byte and 8-byte:
# Pragma pack (1)
# Pragma pack (4)
# Pragma pack (8)
Other values are currently ignored. 8-byte alignment is useful when importing data built with the Microsoft compiler, which defaults to putting double values on 8-byte boundaries.
# AliasIs like# Include, Could t that the macro arguments are assumed to be on one line, separated by space. Also# AliasMacro can itself contain preprocessor statements by using '@'. Otherwise # has the usual meanings. For example:
;> # Alias cd (x) @ cd x @ pwd
;> Cd fred
Expands
# Cd fred
# Pwd
; ># Alias sh (x) show (# x );
;> Sh tommy
Expands
Show ("tommy ");
Built-in Functions
The following library functions are already available:
Sin, cos, exp, log, atof, atoi, rand
Strcpy, strncpy, strcat, strcmp, strdup, strtok, strstr, strlen, memmove
Puts, printf, sprintf, gets, fgets, fprintf, fscanf, fread, fwrite, feof,
Fopen, fclose, fflush
These are of course not the whole C Runtime library, but it's quite easy to add them using the # lib feature as discussed above. See Include file for an example.
You may find it necessary to put empty stdio. H, etc headers in
Include directory for compatibility with traditional systems.
An example transcript
Underc Development Project, vs 0.9.0w
Steve Donovan, 2001
;> // Demonstrating STD: String
;>String s = "hello dolly ";
;>S. substr (0, 5 );
(String) 'hello'
;>S. substr (s. find ("dolly"), 5 );
(String) 'dolil'
;>S + = "you're so busy ";
(String &) 'Hello Dolly You're so plain'
;>S. length ();
(INT) 27
;> // Creating a list of strings...
;>List Ls;
Instantiated: list
;>Ls. push_back (s );
;>Ls. push_back ("way back when ");
;>Ls. front ();
(String &) 'Hello dolly you're so plain'
;>Ls. back ();
(String &) 'way back when'
;>Ls. push_front ("singing ...");
;>Typedef list LS;
;>LS: iterator li;
;>For (li = ls. begin (); li! = Ls. end (); ++ li)
;>Cout
Singing...
Hello dolly you're so busy
Way back when
;>// Demonstrating vectors...
;>Vector Vi;
Instantiated: vector
;>For (int I = 0; I
;>Vi. push_back (I );
;> Vi [9];
(Int &) 9
;>// A useful shortcut!
;># Define FORALL (I, c )/
;>For (I = c. begin (); I! = C. end (); ++ I)
;>Vector : Iterator ii;
;>Int sum = 0;
;>FORALL (ii, vi) sum + = * ii;
;>Sum;
(Int) sum = 45
;>// Typing in a function (can be overloaded)
;>Int sqr (int I) {return I * I ;}
;>Sqr (10 );
(INT) 100
;>Double sqr (double x) {return x * x ;}
;>Sqr (1, 1.2 );
(Double) 1.44
;>// The function main is special
;>Int main (){
;: 1}Int I, j;
;: 1}Cin> I> j;
;: 1}Cout
;: 1}}
;># R
10 20
I + J = 30
;># Q
You coshould have executed main () directly, but using # R forces
Function to run in its own thread and window (at least for the Windows version)