Tuesday, June 3, 2008

cool Firefox add-on


I am still struggling to make my peace with Firefox 3-beta recently...

But a new issue that has bothered me enough that I have had to switch to using IE on the Windows XP system at work, is that pages with lots of Flash or Java script content takes way too long to load and the browser completely freezes another 30 seconds - 1 minute after that.

I have tried the obvious things:
  • disable all add-ons
  • uninstall all add-ons
  • uninstall/reinstall Firefox
Switched back to using 2.0.0.14 which got me back all my Add-ons, but didn't still rid me of the problem.

Anyways, in the frustration, I stumbled onto a damn cool add-on call Tab Effect. Its a "Ubuntu desktop-effects-cube-inspired" transition between multiple tabs. And as expected, it is still not available for Firefox 3.

Oh well, I still need to find a solution to my Firefox woes.

header guard

When working on large software development projects, you often include header files from various parts of the source repository and a cool trick to avoid redefinitions is by use of "header guard".

The concept is fairly simple. Consider the following header files:
foo.h
-----
typedef struct {
int x;
} foo;


bar.h
-----
#include "foo.h"
typedef struct {
foo f;
} bar;


Now when you include these files as follows:
mainfile.c
----------
#include "foo.h"
#include "bar.h"
.....
.....


Obviously you will run into a "redefinition" error when compiled.

The solution:
Place
#ifndef /* unique symbol is generally some form of the file name */
#define
at the beginning of the header file, and
#endif
at the end of the header file.

What this does is that the first time the unique symbol is encountered, the symbol gets defined and none of the definitions in the header file are then redefined.

So foo.h would look like:
#ifndef _FOO_H_
#define _FOO_H_
typedef struct {
int x;
} foo;
#endif /* _FOO_H_ */


and bar.h is like:
#ifndef _BAR_H_
#define _BAR_H_
#include "foo.h"
typedef struct {
foo f;
} bar;
#endif /* _BAR_H_ */