Tag: visual studio

Entries for tag "visual studio", ordered from most recent. Entry count: 62.

Warning! Some information on this page is older than 6 years now. I keep it for reference, but it probably doesn't reflect my current knowledge and beliefs.

Pages: > 1 2 3 4 5 6 ... 8 >

# Documentation in Visual CPP

Fri
15
Apr 2011

Beginner programmers use only tutorials and are afraid of original documentation of any library. Most of programmers I know who use Visual C++ - even advanced ones - search for functions and classes documentation in Google, always being pointed to online version of MSDN Library. That's probably why noone told me about new Visual Studio documentation for such a long time.

But I can't imagine coding without having documentation for every library I use installed offline in my system and opened most of the time. For WinAPI, .NET, C and C++ standard libraries I used MSDN Library for Visual Studio 2008 SP1 - a free application that is available for download from Microsoft website in form of a DVD ISO image. But it's a 2008 version. I checked for some new version many times and couldn't find one.

Now I know that Microsoft changed this offline MSDN Library to a new help available in Visual Studio 2010, including Express edition. It can be installed by selecting Help / Manage Help Settings. A dialog box allows you to install, remove and update different parts of huge library (mine takes 3 GB of hard disk and it's located in C:\Users\All Users\Microsoft\HelpLibrary)

Files are downloaded, installed and after that, you can use Microsoft Help Viewer 1.1 to browse this documentation - hierarchical Contents, flat Index (I think it's the most useful), Favorites and full-text search. This help browser works faster than the old one (from MSDN Library). I recommend this method to anyone who code in Visual C++/C#/whatever.


Comments | #visual studio Share

# Pointing to DLL Files in Visual CPP

Tue
12
Apr 2011

When coding in Visual C++, we sometimes need to use some DLL libraries like FMOD, wxWidgets, Intel TBB etc. We download or build the library, setup directories to include and library files, finally #include <header.h>, #pragma comment(lib, "library.lib"), compile, run and...

Certainly our program also needs DLL file at runtime. Sure we have to attach it to the program when we distribute it, but do we really need to copy all these libraries to the Debug and Release subdirectories in our project? For a project run from Visual C++ to find required DLL files, they must be placed either in:

or in the PATH environmental variable. That's an option I've discovered yesterday. To use it in Visual C++, navigate to project properties / Configuration Properties / Debugging / Environment and set it to something like: PATH=$(PATH)$;C:\my_libraries\library_1\DLL_dir

If you do it correctly, your program launched from Visual C++ (with or without debugger - F5 or Ctrl+F5) will now be able to find required DLL libraries without need to copy them to your project directory.

Comments | #windows #c++ #visual studio Share

# Static C++ Code Analysis with PVS-Studio

Sat
12
Mar 2011

By the courtesy of its authors, I have a chance to evaluate PVS-Studio - a static code analyzer for C, C++ and C++0x. This commercial application is installed as a plugin in Visual Studio 2005/2008/2010. Fortunately I have Visual Studio 2008 Professional at home so I could try it with the code of my personal projects. PVS-Studio differs from other tools of this kind, like free Cppcheck, by finding three types of errors or warnings: general, related to OpenMP and 64-bit portability issues.

After opening my solution in Visual Studio, I choose a command from the special menu to analyze all the code.

A progressbar appears while PVS-Studio does the computations, utilizing almost 100% of all 4 CPU cores. Finally, a dockable panel appears with a list of found issues.

The general category warns about exact float comparison with == and stuff like that. It managed to find few places where I forgot the "&" character while passing a vector as const refefence parameter, rightly telling that it will cause "decreased performance". But its greatest find in my CommonLib library code was this unbelievable bug:

Some messages look funny. Should I code some general, abstract, portable, object-oriented, Alexandrescu-style template-based solution here just to avoid copying some code into several similar instructions? :)

I didn't check how the OpenMP validation works because I don't currently use this extension. As for 64-bit compatibility issues, I have lots of them - just because my code is not prepared to be compiled as 64-bit. PVS-Studio seem to do a good job pointing to places where fixed-length 32-bit integers are mixed with pointers, array indexing etc.

Overall, PVS-Studio looks like a good tool for C++ programmers who care about the quality of their code. Finding issues related to OpenMP and 64-bit compatibility can be something of a great value, if only you need such features.

Too bad that PVS-Studio, opposite to Cppcheck, is a Visual Studio plugin, not a standalone application, so it obviously requires you to have a commercial MSVS version and do not work with Express edition. But this is understandable - if you need OpenMP or 64-bit, you probably already use Visual Studio Professional or higher.

PVS-Studio analyzes C, C++ and C++0x. It doesn't work with C++/CLI language, but that's not a big flaw too. I use C++/CLI at work, but I can see it's quite unpopular, niche language. Its compilation or analysis would also be very difficult because it mixes all features from both native C++ and .NET. Even Microsoft didn't find resources to implement IntelliSense for C++/CLI in Visual Studio 2010.

Comments | #tools #c++ #software engineering #visual studio #pvs-studio Share

# Visual Studio 2010 Service Pack 1 Released Yesterday

Fri
11
Mar 2011

Yesterday Microsoft publicly released Visual Studio 2010 Service Pack 1. It is big (1.48 GB) and the installation takes quite long. It applies to all Visual Studio 2010 versions and components, including C++ Express, C# Express etc. Here is the list of changes and here is download link (you can find link to ISO file with offline installer at the bottom of that page). There are lots of fixes and improvements, but most of them apply to managed or web technologies like Silverlight. What's interesting for a C++ programmer is the addition of intrinsics to enable the extensions on the AMD and Intel new microprocessors that will be released next year - Intel AVX and AMD Bulldozer. Microsoft also claims to optimize and fix C++ compiler. Changelist mentions fixing lots of IDE crashes, including incompatibility with AMD CodeAnalyst.

Overall I think the new SP1 for VS2010 is worth installing, unless you have "Windows SDK for Windows 7 and .NET Framework 4" installed in your system. In that case an unsolved issue would happen so you should NOT install the Service Pack.

By the way: MSDN Library - the extensive documentation of C, C++, WinAPI, OpenGL, .NET and lots of other technologies - is available for free in form of an offline application for some time, but the latest version is MSDN Library for Visual Studio 2008 SP1. Do you know how to download some newer release? Or maybe that "Windows SDK" ships with it?

Comments | #c++ #visual studio #windows Share

# Generating LIB File for DLL Library

Tue
04
Jan 2011

I've been recently trying to use libVLC - functionality of great, codec-less VLC media player enclosed in form of DLL library. By the way I've came across a great article: GenerateLibFromDll and now I know how to generate LIB file for any DLL library! Here is detailed description of the problem:

When you have a DLL library you want to use in your C++ code, you may do it dynamically by using LoadLibrary and GetProcAddress functions from WinAPI, but it's more convenient to do it statically. But it's not enough to just #include signatures of library functions and use them in your project. You also need to link with some LIB file, even if the file is not a real static library with compiled code, but only a few-kilobyte-long list of imported functions. I believe that's just another flaw of C++ language, because other languages like for example C# don't need this even when importing functions from native DLL libraries.

If you have some SDK prepared for Visual C++ or compile the library by yourself, you also get the LIB file next to DLL. But if you have only the library, that article shows following steps to generate matching LIB:

1. From Start menu run "Visual Studio Command Prompt".

2. Execute command:

dumpbin /exports DLL_FILE.dll > DEF_FILE.def

This command prints some information about given DLL library in textual form to its standard output. We redirect it to a text file with DEF extension. But to make it real DEF file, we need to edit it.

3. Open DEF_FILE.def in some text editor and edit it to contain only the names of exported functions in form of:

EXPORTS
function_1_name
function_2_name
function_3_name
...

4. From the Visual Studio Command Prompt, execute another command:

lib /def:DEF_FILE.def /out:LIB_FILE.lib /machine:x86

And there you have it! The so much required LIB file generated from DLL library. You only need signatures of these functions with proper parameters and return values declared in some H header file and you can successfully use your DLL by linking with LIB file created by yourself :)

Comments | #visual studio #c++ #windows #winapi Share

# Compiling wxWidgets 2.9.0 in Visual C++ 2010 Express

Thu
06
May 2010

NEW! (2011-02-18) I posted this entry months ago, wxWidgets keeps evolving and so it may no longer work. For building wxWidgets 2.9.1 in Visual C++ 2010, I now recommend you follow steps described here: Visual Studio C++ 2010 - Microsoft Visual C++ Guide - wiki.wxwidgets.org and here: Fixed wxWidgets 2.9.1 project files Visual Studio 2010 - forums.wxwidgets.org.

My old blog entry:

Today I wanted to compile wxWidgets library (version 2.9.0, which contains lots of interesting new features, including wxPropertyGrid control) under Visual C++ 2010 Express. A strange error appeared that stopped the build and explained nothing specific about the cause:

Microsoft.CppCommon.targets(151,5): error MSB6001: Invalid command line switch for "cmd.exe". The path is not of a legal form.

It took me some time to find a correct solution on Google, as many of them didn't work. (Copy setup.h file to some another directory? Made no difference in my case. Use the wx.dsw - project file for oldest IDE version? Didn't work either, my Visual says it cannot import such projects.)

Finally I've found this forum topic: http://forums.wxwidgets.org/viewtopic.php?t=27630. Sami Hamlaoui on 25th April 2010 posted a ZIP archive there containing converted and fixed project for Visual C++ 2010 that you can download and use to successfully build wxWidgets 2.9.0. Thanks for that!

After you build all projects in Debug and Release configuration, you just need to setup include and library paths in the IDE:

...\wxWidgets-2.9.0\include
...\wxWidgets-2.9.0\include\msvc

...\wxWidgets-2.9.0\lib\vc_lib

And finally you can use wxWidgets in your projects. To do that, you need to #include files such as and link with these libraries:

comctl32.lib, rpcrt4.lib, winmm.lib, advapi32.lib, wsock32.lib

and desired wx libraries like wxbase29ud.lib and wxmsw29ud_core.lib ("d" is for debug, use versions without "d" in Release configuration). Also remember that the new wxWidgets has no ASCII support, so you have to use Unicode character set.

Comments | #wxwidgets #visual studio Share

# DXGI Format Cheatsheet

Thu
29
Apr 2010

Today I've prepared another small, single page cheat sheet related to DirectX 11:

DXGI_Format_Cheatsheet.pdf
DXGI_Format_Cheatsheet.odt

I've also solved my problem with Visual C++ 2010 Express that crashed every compilation on my computer. I've submitted this bug to Microsoft Connect, expecting that it may be because I have a 64-bit Windows 7 or because I also have Visual Studio 2008 Professional installed. But with the help from Microsoft I've figured out that it was just because of the AMD CodeAnalyst profiler. Uninstalling this program helped me so my VC2010 doesn't crash any more :D

Comments | #visual studio #directx #rendering Share

# C primer for C++ programmers

Sun
27
Sep 2009

I've never learnt pure C programming language, only C++. It does not mean I never use global variables or fopen function, but I it makes no sense for me to code in pure C when there is a C++ compiler available. But today I've decided to skim the classic book "The C Programming Language" by Brian W. Kernighan and Dennis Ritchie. Here is what I've found out:

You can actually code in C using Visual C++. To do this, you need to: (+) Create empty project, (+) Add a file with .c extension, (+) Enter project options, (+) Nagivate to Configuration Properties / C/C++ / Advanced, (+) Set "Compile As" to "Compile as C Code (/TC)".

The C language is similar to C++ except it lacks features such as:

There are some differences between C++ and C though. For example, you don't have to state type of function parameter or return type if you want to it to default to int. Following lines are equivalent:

int MyFunc1(int a, int b) { }
MyFunc2(a, b) { }

Compiler is generally more liberal when it comes to type checking and function calling. You can call function with more arguments than expected and it only generates warning. You can declare function with empty parameter list like MyFunc() which means unknown parameter list! To explicitly state that a function takes 0 parameters you have to write MyFunc(void).

Local variables can be defined only before any other statements in a block. You also cannot define a variable inside for loop. Example:

void Func(void)
{
  int a = 1; // OK
  Foo();
  int b = 2; // Error!
  {
    int c = 3; // OK
  }
}

C requires different syntax for using structures. If you define a structure like this:

struct Struct1 { int x; };

You have to prefix the name of this type with "struct" keyword each time you use it, just like this:

struct Struct1 *myObj;

But luckily typedef construct works in C, so the common solution to this problem is to use it like this:

typedef struct { int x; } Struct1;
...
Struct1 *myObj;

Comments | #c++ #c #visual studio Share

Pages: > 1 2 3 4 5 6 ... 8 >

[Download] [Dropbox] [pub] [Mirror] [Privacy policy]
Copyright © 2004-2024