Archive for February, 2012
The smallest C program possible
Posted by scanff in Random Discussion, Windows C++ Programming on February 20, 2012
Interestingly the smallest C program you can write in windows is.
int main[] = {0xC3};
Basically the same as.
#include
int main()
{
return 0;
}
Also I’m assuming you are using a X86 processor and the 0xC3 is just a return (RET).
Years of development? Free up your HD!
Posted by scanff in Random Development on February 20, 2012
Here’s a really simple tip for any windows developer frustrated by the clutter created by their old code projects. Use this information at your own risk, if you delete something important don’t blame me :/ I take no responsibility for any loss!
I tend to back up my code by grabbing the folder and dumping it on my backup drive. Unless you’re a very organized person you may have duplicates of the same project all containing a mega amount of build, object, compiler and other junk files. This was getting a little ridiculous my “code dump” folder was over 10GB – surely source files aren’t that big!
After browsing around I noticed that the majority of the space was taken up by object, build and the IDE internal files. I noticed the biggest offender to be Visual Studio, it creates .sdf and .ndb file that can be hundreds of megabytes. I attempted to manually delete these files but after a few minutes decided to make a tiny little old school DOS script to do the work.
Create a text file with the following script and give it the extension .bat. Replace %WHEREYOUWANTTOCLEAN% with the location the script needs to start, i.e. c:\mycode
#assume c drive, change if you are cleaning another drive
c:
cd %WHEREYOUWANTTOCLEAN%
del *.sdf /S
del *.obj /S
del *.o /S
del *.d /S
del *.tmp /S
del *.pdb /S
del *.ilk /S
del *.ndb /S
What are these files? Okay here’s what you’re deleting :-
.sdf – Used and created by Visual Studio this looks like an internal DB file. The .sdf format is described as.
Compact relational database developed by Microsoft, also known the SQL Server Compact (SQL CE) format; designed for applications that run on mobile devices and desktops; contains the complete database contents and can be up to 4GB in size.
** NOT very “compact” though, many I found were 50MB large :/
.obj – Compiled Object File
Usually created by Visual Studio, it’s the binary representation of your source file. Deleting will just require the project to rebuild it the next time you run.
.o – Compiled Object File
Usually created by gcc/mingw, it’s the binary representation of your source file. Deleting will just require the project to rebuild it the next time you run.
.d – Compiled Object File
Usually created by gcc/mingw, it’s the binary representation of your source file. Deleting will just require the project to rebuild it the next time you run.
.tmp – temporary files
You should know what these are!
.pdb – Program database
This file contains information used when debugging and can get very large.
ilk – Incremental Linking File
Used by Visual Studio when linking the project.
.ndb – Another Visual Studio database file
This looks like another internal database file used by Visual Studio and can get very large.
After deleting these files I recovered 4GB on my hard drive
I’m sure there are a bunch of other files that can be safely removed, feel free to comment if you know of any.