Visual Studio 2008 / 2010 GOTCHA's

VS just royally screwed me over again...so I figured that I could start a list of items that are a bit counter-intuitive with the IDE. If anyone else has some to add, please do.

1) Copying files between projects in the same solution within the IDE DOES NOT ACTUALLY COPY the files. Any changes made to any of the "shortcuts" will affect the file(s) that you were planning on not modifying. In order to copy the files you will need to do it with the actual file-system.

2) Even though VS2010 has installs the <initializer_list> header, it doesn't work and yields output similiar to this:
c:\program files\microsoft visual studio 10.0\vc\include\initializer_list(13): error C2143: syntax error : missing ';' before ''template<''
Microsoft wrote:
As you probably know, we license our C++ Standard Library implementation from Dinkumware, whose master sources target many compilers. When we updated our implementation to the latest version of their master sources, we picked up their support for initializer lists in addition to rvalue references, forward_list, and so forth. Because we decided against implementing initializer lists in the VC10 compiler (due to time constraints, we picked 6 Core Language features to implement in VC10), I stripped out the support for initializer lists that had made it into our headers (it was protected by a macro that was never defined). Unfortunately, I simply forgot that we had picked up <initializer_list> itself. Oops.


3) TODO: later
Last edited on
closed account (S6k9GNh0)
Most of the extensions are rather strange. A rather lengthy and strange bug to find was the following:

1
2
3
myCtor::myCtor(myNonCopyableClass& lol)
: member_nccInstance(myNonCopyableClass(lol))
{}


I'm not sure if this is an exact working replica (as the conditions aren't quite the same as the strange behavior I found) but as you can see, we try and copy a non-copyable class which should error but won't. Instead, undefined behavior occurred, often causing strange things to happen with member_nccInstance. In a thread application in my case, this bug required me to use gcc, which won't compile this by default.

I have *quite* a few others that I've found myself using some rather lanky work around for. Although, I will say I sometimes do the same for GCC, credit for no one. Also, the next VC++ compiler may or may not be up to date with the C++0x draft. It's noted everywhere by there team although I at least hope they get initializer lists working.
Last edited on
I would like to add something simple, which most people are probably aware of but I thought I'd mention for those who are not. This is for people that are using C to make their libs for their C++ programs.


Be careful with Visual Studio when you are trying to compile code in C and not C++. Remember, the Visual C/C++ compiler is one program, not two (if I understand correctly). By default Visual Studio will try to compile in C++ even (sometimes) when you have your files named as .c and not .cpp.

To change your project's compile settings, do the following:

1. right click on your project
2. click properties
3. click on C/C++
4. click on advanced
5. set the property "compile as" to C Code (/TC)
6. rename your .cpp files to .c

This will force the IDE to compile in C and not C++.

Last edited on
By default Visual Studio will try to compile in C++ even (sometimes) when you have your files named as .c and not .cpp.
I've never seen this behavior. In fact, I've observed the exact opposite. If you add files with the proper extension, the IDE will correctly mark them as C, C++, or non-compilable.
Yes I believe in VS2010 they have corrected some bugs around that (it doesn't seem to happen to me either), but I have seen some people on rare occasions experiencing difficulties in VS2008.

So its always good to make sure the IDE is "forced" into doing what you want it to do.

Does anyone know how to include STL documentation?

I have noticed that there is none. It seems microsoft can provide a ton of documentation tags for .NET and none for C++.

It would be nice to see std::vector...[creates a vector<T>, a container of the STL that has random access capability, blah blah blah]
Topic archived. No new replies allowed.