Category: How To

Printing the gcc predefined macros to stdout

Any time you wanted to know the list of gcc used macros and their values. Here is the command details

touch foo.h; gcc -dM -E foo.h

will list all the macros used.

The option

-dM will generate the list of all #defines used by the pre-processor during execution, this also includes pre-defined macros.

-E will stop the compiler after pre-processing stage. Will not enter to the compiling stage. The output will be in the preprocessed form and will be sent to the stdout.

Android Based Smart Watches Unveiled

Pebbles made several heads turn at CES 2013, Las Vegas as it unveiled an Android based Smart Watch at the event.

The Smart Watch has an Android 2 operating system specially developed by the company for the watch. It can be connected to your phone via Bluetooth to receive calls, text messages and even interact on social networking platforms like Facebook and Twitter.

Read More…

Find a pattern and then do search and replace of a word.

I was having a file with format as below.
1. Different fields with a field seperator.
2. Multiple lines.
3. There were multiple lines with same strings to be replaced but there are few lines to match a pattern string to execute find and replace.

Used the following vi editor command.
:%g/^.*pattern*.$/s/find/replace/g
where,
%g for using regular expression command in vi.
^.*pattern*.$ for searching and selecting lines containing the (semi-)word pattern.
s/find/replace/g for string find words with value “find” and replace them with string “replace”.