by
Jacob on
28 Apr 2008 in
Programming
You’re writing some C code that you just managed to compile. You are able to get it to build without errors, and you’re ready to run. But then, something disastrous happens:
$ gcc main.c -o out
$ ./out
Segmentation fault
Great. Your application dies without so much as an explanation as to why. Nobody likes to debug code, but it has to be done at some point. If you compiled with the -g flag to gcc or g++, your program will have some debugging information included that special programs, like gdb, can use to assist you in solving the problem.
Nemiver is a graphical tool that can be used to take advantage of debugging information that uses gdb as a backend. It provides all of the features that the terminal-based gdb provides, but in a more sophisticated GUI interface that follows the code as it is executed. This means you can run code line-by-line, add breakpoints, view pointers, variables, memory registers, and see the call stack. In addition, you are also able to attach to a program over a network; so if your web server application goes down, you can run it over-the-wire with Nemiver to try to solve the problem.

Read the rest of Debugging with Nemiver
by
Peter on
24 Apr 2008 in
Apps
Keeping organised can be tough sometimes and there are lots of different applications and tools designed to help you get organised.
Tasque is designed to be a very simple todo list application, designed specifically to link in with popular online todo service Remember The Milk.
It is written in C#/Mono, so you will need all the relevant Mono gubbins already installed to get it up and running. Here on Fedora 8, there isn’t a package yet, so I’ll run you through how to install it from source.
First of all, head to the Tasque download page and download the archive in whichever format you want. Once you’ve got it, extract it somewhere, then open a terminal in that directory.
Read the rest of Tasque - a simple todo list application for GNOME
by
Jacob on
28 Nov 2007 in
Programming
If you haven’t read the previous tutorial, we highly recommend you do so. Otherwise, you might miss important concepts used here.
Go ahead and fire up a text editor, and begin reading and typing. The meat of this tutorial is in the comments. Remember, try typing it out instead of copying and pasting. This way you will be able to remember by doing instead of by reading.
#include <iostream>
/* First off: let's make a basic function that prints "Hello" on the screen.
* The syntax for a basic function is as follows:
** returnType functionName()
* Like with main(), you can return an int if you want, but with normal
* functions it is possible to return nothing (void).
*/
void sayHello(){
std::cout << "Hello from a function!" << std::endl;
/* Here is something new. std::endl (or just endl if you used the namespace
* mentioned in the previous lesson) inserts a new line into the console.
* Get into the habit of adding it to cout statements for readibility.
*/
}
/* Notice how using void as a return type means we don't have to return
* anything. For a quick example, let's make a function that does return
* something.
*/
int threeTimesThree(){
int result;
/* Woah, we haven't seen this before. This is simply known as a variable.
* Basically, it stores data. But before you can store anything, you need
* to tell the compiler what type of data you want to store. This is
* specified here with "int". So, we just made an integer named "result".
*/
result = 3 * 3;
/* To set a variable to something, just use the syntax
** variable = value;
* Value can be a single value, a calculation, or the result of another
* function. But, it has to be of the same type that you defined it as
* above. result should equal 9 right now.
*/
return result;
/* As with main(), if we set a return type we need to actually return
* something. Here, we are returning the variable result.
*/
}
/* What if you want to pass a variable to your function? That is when arguments
* come in handy. They aren't much more difficult to use than a simple
* variable:
*/
int multiply(int number1, int number2){
/* You can have as many arguments as you want, and name them whatever you want.
* They can be used in your function as a simple variable.
*/
int result = number1 * number2;
// This is an example of defining and setting a variable at the same time.
return result;
}
// Of course, we need our usual main() function.
int main(){
/* To call a function, use the same syntax you did for defining it, except
* without the type before it. If a function returns a value, you can
* assign it to a variable.
*/
// Print out hello
sayHello();
int answer = threeTimesThree();
std::cout << answer << std::endl;
// You can use variables in a cout statement as well.
// If you like, you can even use a function directly.
std::cout << multiply(4, 5) << std::endl;
// Finally, finish up our main() function with a return.
return 0;
}
Compile it (if you forget how, see the previous tutorial) and run. You should get something like:
./test
Hello from a function!
9
20
If not, or you got an error, check your code and see if you mistyped anything. If you are still having trouble, post a comment and I’ll try to help you out.
We hope you enjoyed this tutorial. Stay tuned for more!