Saturday, November 8, 2008

Where to define your global variables?

In C/C++ project, where to define the global variables is a question. If you define them in the header file, you may encounter the link2005 error about objects redefined.

The formal way to define global variables is to define them in C or CPP file, and declare them in the header file by using extern keyword.

Cannot delete pdb file when compiling VC project

When using VS.net 2003, you may encounter this problem. once this problem happens, you cannot build you project any more. I have no idea about why this happens (Maybe there are some debuggers of your project have not been terminated normally), but I can tell you how to solve it.
cut the project.pdb and move to another folder. Yes, you cannot delete it, but you can move or rename it. Then, you can build your project as usual. It's easy, doesn't it? :p