Category: visual studio

Did you know? Visual Studio is 32-bit only!

Did you know? Visual Studio is 32-bit only!

ITask Manager screenshott’s quite surprising that in this day and age, that there is still 32-bit software in use. Visual Studio is a prime example.   Windows has been 64-bit for quite a while now.

If you look in Task Manager, you’ll probably notice that programs with a (32 bit) after their name are few and far between.

On the screenshot, only one out of 11 is 32-bit and that’s pretty typical.  Linux and Mac are probably similar.  Here’s a stackexchange question on how to tell if a process is 32 or 64 bit.

In Visual Studio, it’s very easy to switch between 32-bit or 64-bit compile target. Unless I have a real need, I go for 32-bit for programs I write because they are typically not going to need over 4 GB of RAM. And 32-bit code usually runs faster than 64-bit because instructions are typically shorter which means more instructions in the execution cache etc.

However some systems have a lot of code and there are people who want a 64-bit version of Visual Studio.  You can read some of their requests here.

I’m still on a Linux laptop BTW. My new cooler has turned up and tomorrow I hope to install it. The Windows screenshot came from my work laptop which I emailed to myself!

How to count lines of code in Visual Studio

How to count lines of code in Visual Studio

Calucating Code metrics in Visual StudioUntil this morning, I didn’t realise that Visual Studio (even the free Community Edition) has this built in. I was curious to see how much code I’d written so far for my game processing engine.  Development comes in leaps and bounds during evenings and weekends.

Visual Studio has Code Metrics in it. You can do this for any project that builds correctly. To show this you have to do View => Other Windows => Code Metrics Results. That displays the window. Then you have to go on the Analyze Window, and click Calculate Code Metrics.

Lines of code

However you might want to take these with a pinch of salt. As I understand it, Lines of Source Code is calculated from the il code output from the compiler. The last column (Lines of executable code) suggests that most of my program is comments which is wrong! There is however a fair amount of data in the form of Constructor initializations, and one file of 1290 lines has over 1,000 such initializations.  You can read what the other columns mean and everything you ever wanted to know about code metrics on the Microsoft site.

Out of curiosity, I manually counted the number of lines in this project. There are 15 files and they added up to 3700 lines but that includes comments and blank lines.  A quick search for // found 119 which probably means I should improve my commenting. Blank lines is probably something similar. So we’re talking 3700-1000 (constructor initializers)-119 (comments) -119 (blank lines) = 2462 lines of code so far. That’s working tested code mind you.

 

C11 and C17 support in MSVC

C11 and C17 support in MSVC

 

The letter C
Image by Peggy und Marco Lachmann-Anke from Pixabay

Microsoft have announced that they will be supporting both C11 and C17 in Visual Studio 2019 version 16.8 Preview 3. All the required features but not optional features and not VLAs (Variable Length Arrays) which is considered unsafe.

One of the complaints has been that Microsoft always prioritised C++ over C for many years. C was supported inasmuch as it was needed for C++. Until fairly recently C++ was a superset of C and you could compile C program as C++. Just change the extension to .cpp.

That said, I will probably continue to write C code as C99 for now and take a look at the C11/C17 features such as restrict, stdnoreturn and so on.  Note C17 is considered a bit of a bug fix for C11.