Wednesday, August 5, 2009

extern/static in function declaration

I have never really paid attention to the 'extern' keyword in a function declaration, so here is my understanding of this.

In C:

In the simplest form, the 'extern' keyword changes the linkage so that the resolving is deferred to the linker. It is assumed that the function is defined/available somewhere else.

Whereas a 'static' keyword when declaring a function, it makes the function local to that file.

I suppose if you don't use the extern/static keyword when declaring the function, it defaults to extern.

static c variables are of course different than non-static variables.

In C++:

'static' functions in C++ have a very different usage. A static member function of a class is generally called without having to instantiate an object of the class. This is same for the static member variables of the class as well.

The static functions do have their limitations:

  • A static member function can access only static member data, static member functions and data and functions outside the class.
  • A static member function cannot be declared virtual, whereas a non-static member functions can be declared as virtual.
  • A static member function cannot have access to the 'this' pointer of the class.

wubi and update to new release

I have been recommending Wubi to a lot of folks as a simple way to switch to using Ubuntu without having to worry about partitioning, etc. Wikipedia has a pretty good write-up on Wubi.

The problem, as I had expected, is that upgrading to a new release when available comes with a host of problems.

This discussion thread talk about the problem. It is fairly recent, so I don't think there is a solution for this yet. Does anybody have some different information?

Tuesday, August 4, 2009

which version?

I keep having to look up which version of the distribution I am running and like every thing Linux, every distribution has decided to use it's own way.

For Ubuntu:
# cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=8.04
DISTRIB_CODENAME=hardy
DISTRIB_DESCRIPTION="Ubuntu 8.04.3 LTS"


For RedHat/Fedora:

#cat /etc/redhat-release


For SUSE:
$ cat /etc/SuSE-release
openSUSE 11.1 (i586)
VERSION = 11.1

Monday, July 27, 2009

Sunday, July 26, 2009

msft drivers for Linux

This has been all over tech news last week. Microsoft contributing code to the kernel (GPL for the first time). The drivers help Linux run better on a Windows host.

http://news.cnet.com/8301-13860_3-10290818-56.html

I like the note at the bottom of the article...
"For those that want to hear Microsoft's take on the news, here's a video of Hanrahan discussing the move with Sam Ramji, the company's senior director of platform strategy. (Note: Silverlight is required.) "

Irony anyone?

Thursday, July 16, 2009

crowdsourcing to find answers



I have been using stackoverflow every so often to get answers and it's generally to questions others have asked.

Figured it's finally time to get a little more proactive in looking for answers by asking the questions myself.
http://stackoverflow.com/questions/1134931/reading-understanding-third-party-code

use gcc to help you deprecate methods/functions in c/c++

Every so often you need to deprecate/remove/rename classes and functions in a very large project. Rather than grep'ing your way through the large source tree and trial-&-error method of compiling the project, a good way to do this would be to use the __attribute__ macro.

You assign the "deprecated" attribute to the variables, functions, methods that you plan to phase out.

GCC will cause a warning at all the places it is called.

example:
class Foo {
public: Foo() __attribute__((deprecated)) {}
};

The thing to check would be that you are not using -Wno-deprecated-declarations when building.

Since I recently switched over to using NetBeans, I can do a "Find Usages" in the entire project, but very often your project only covers the part of the code base you personally have been working on.