Tuesday, May 13, 2008

Wanna see how your MACROS are expanded?

#define

#include

#if

#ifdef

These, you know, are some of the preprocessor directives that we normally get to see in any program. There times when you feel its necessary to see what exactly the preprocessor has understood from the directive. For example, you might wanna know if your MARCO got defined as expected. Consider the code below.

 

#define MACRO1 1 + 2

#define MACRO2 1 - MACRO1

int main(){

int a=MACRO2;

cout << a << endl;

return 0;

}

To see the preprocessor output, use the gcc with -E option to compile the code. The output will be printed on screen itself.

[balaji1@cheud216][/home/balaji1]$ gcc -E temp.C

# 1 "temp.C"

# 1 "<built-in>"

# 1 "<command line>"

# 1 "temp.C"

 

int main(){

int a=1 - 1 + 2;

cout << a << endl;

return 0;

}

Likewise, if you have a #include <iostream.h>, you'll get to see the whole of iostream.h printed along with your code after 'gccing' as mentioned above.

 

The -E option can be used with any other compile time option in gcc (or g++). In case a make command is used for compilation, you may get to see gcc or g++ being used with many other options to compile a file. Just include -E to all those options and do a compilation again to get the preprocessed output.

Submarine cable systems across the globe

I ran into this link  on 10/14/2007.
 

You can find all the major submarine cable networks in the world.  
 
 
Click on the LOOK button in the bottom left hand corner of the graphic to see a flash animation of how the network got laid. Also check out NEC's other projects too (the links below Our Record in the left hand corner).

Killing all processes

Here's the command to kill all process belonging to current user in solaris.
 
kill -9 -1
 
where 9 => number equivalent for SIGKILL