This week I have started working in my first task in the project , after spending the last couple of weeks studying and digging here and there … the real work has just begun 😀 ..

Last week and as I mentioned in my previous blog entry I managed to integrate the code editor (codemirror) with witty. So my first task was to both save the content of the editor to the server and to load some code from the server to the browser. I spent the first couple of days trying to figure out how to do this . But Finally the loading part was completed successfully using JQUERY get function , but the problems started as we began working with the saving part . First we did trying saving the content of the editor using the JSignal .. Jsignal object will emit a signal with the content of the editor whenever certain event occurs then another function at the server side will be responsible for handling this signal and writing the content of the editor to a file. This technique worked successfully but then Dr.Shawn asked us to use the WResource instead of using Jsignal as the latest could cause certain problems as the project progresses.

The last two days I started the second task which was compiling the file that contains the content of the editor using “g++ -S -o /dev/null -xc++ -Wall -fsyntax-only
For executing any shell commands from the code , there are bunch of functions that can be used to do this task such as System() and popen(). For simplicity I used system() and I redirected the output of the command to a file instead of the terminal and when I opened the file … SURPRISE .. There was NOTHING inside. At the beginning I suspected the function system() and I tried to use other functions . But the same problem was there too. .. The output of the compilation was not written inside the file.

Later, I found out that there are three standard files (standard streams) stdin,stdout and stderr.

  • stdin – Use to get input (keyboard) i.e. data going into a program.

  • stdout – Use to write information (screen)

  • stderr – Use to write error message (screen)

The output of the compilation is an error message and it’s usually written in the

stderr stream. So What I was doing “Stupidly” was trying to redirect the information of stdout (NOTHING) to a file instead of redirecting the stderr output to a file using “ > “ instead of using “2>”.

– “g++ -S -o /dev/null -xc++ -Wall -fsyntax-only file-name.cpp > file-name.txt”  (wrong)

– “g++ -S -o /dev/null -xc++ -Wall -fsyntax-only file-name.cpp 2> file-name.txt”  (right)

For more information about the stdin,stdout and stderr streams and redirection kindly visit the link below: .. It’s really helpful 😀

Any way I was glad that it finally worked. !!!
Cheers! 😀