Tuesday, August 23, 2011

GCC Function Attributes

You can find the set of gcc function attribute options at [1]. If you are a smart C/C++ developer, you should always be concerned about these options.

[1] - http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html

Tuesday, August 2, 2011

Atomic operations in C/C++

The atomic operations provided by GCC [1] come in quite handy even though they are limited to a few data types and in fact Intel-specific. AFAIK SPARC has it's own set of variants.

[1] http://gcc.gnu.org/onlinedocs/gcc-4.4.0/gcc/Atomic-Builtins.html#Atomic-Builtins

Monday, August 1, 2011

SSH/SCP without entering password

It is quite cumbersome if you are to re-enter password each time you invoke scp/ssh. Especially when you have a build system managing hundreds of binaries and scp deploying each of them to a remote run environment.

I found [1] quite useful in that regard.

[1] - http://www.thegeekstuff.com/2008/06/perform-ssh-and-scp-without-entering-password-on-openssh/comment-page-1/#comment-119367

Tuesday, October 19, 2010

_MSC_VER Values

VC6 - 1200
VC7 - 1300
VC7.1 - 1310
VC8 - 1400
VC9 - 1500

WINVER and _WIN32_WINNT Values

NT – 0X0400
2000 - 0x0500
XP - 0X0501
Server 2003 - 0X0502
Vista - 0X0600
Windows 7 - 0X0601

Saturday, October 16, 2010

Two ways to proof of 0.999… = 1

Long Division

1/9 = 0.111...
9 x (1/9) = 9 x 0.111...
1 = 0.999...

Digit Manipulation

X = 0.999...
10X = 9.999...
10X - X = 9.999... - 0.999...
9X = 9
X = 1

Source : http://en.wikipedia.org/wiki/0.999...#Digit_manipulation

Wednesday, October 13, 2010

Hex/int conversion in C

int –> Hex

int i = 10;
void* h =  (void*)i;

Hex –> int

void* h = 0xa;
int i = (int)((const char*)h - (const char*)0);