Windows SDK is installed. I built N++ successfully with Visual C++ 2008 Express before. But now with 2010 I have a lot of error messages about sprintf_s:
1>C:\Program Files\Microsoft Visual Studio 10.0\VC\include\string(676): error C2039: 'sprintf_s' : is not a member of '`global namespace''
1>C:\Program Files\Microsoft Visual Studio 10.0\VC\include\string(676): error C3861: 'sprintf_s': identifier not found
Please help.
There's a property sheet included with the project named no_ms_shit.props (after conversion). There's a fair amount of hate expressed in that sheet for what MS has been trying to do for the past 5 years.
They went a little too over-board with turning everything off, they even disabled linking to sprintf_s(). Which is the source of your error, the stdio.h header omits the declaration but the string header uses it. Not sure if the Express edition supports editing project property sheets, but the step in the retail edition are:
View + Property Manager
Open one of the nodes and locate "no ms shit"
Right-click it, Properties
C/C++, Preprocessor, Preprocessor Definitions
Change __STDC_WANT_SECURELIB__=0 to 1
Add _CRT_SECURE_NO_WARNINGS to those definitions
The project compiles clean now. I do get a build error for copying files, it is a post-build event. Start another question if you can't figure out how to fix it.
Strange. I have Visual Studio 2010 Ultimate, and it even doesn't allow me to access the View->Property Pages menu item. It is disabled for me.
But I just went to the file no_ms_shit.props and edited that in Notepad++ only :). Then went to Project->Properties->Configuration Properties->General, and selected 'No' for treat warnings as Errors, and added _CRT_SECURE_NO_WARNINGS in the preprocessor definitions.
Don Ho should go with the flow than cursing the ms shit when he is developing in Windows and Visual Studio.
This worked for me when using Visual Studio 2012 Professional:
You have to edit no_ms_shit.vsprops (*.vsprops, not only *.props!):
Replace __STDC_WANT_SECURE_LIB__=0 by __STDC_WANT_SECURE_LIB__=1
Add _CRT_SECURE_NO_WARNINGS to the preprocessor definitions.
A closer look at the source would show that most of the library calls that cause endless noise unless you use this property sheet come from the SciLexer.dll project. Scintilla is cross platform, so it doesn't need all the Windows specific cruft.As you mentioned, Microsoft went overboard with their replacing the standard string library, as legitimate as their attempt to avoid buffer overruns may be.
So you may direct this criticism to Neil Hodgson (main developer of Scintilla) rather than Don Ho.
CChris
Related
This problem is making me mad.
We have a set of projects that rely on T4 templates to generate code for a bunch of DSLs.
Every time I try to transform one of these T4 templates in Visual Studio 2015 I get this window, the security warning:
I have set the "Do not show this message again".
I have set the VS option "Text Templating | Show Security Message" to false.
Every time I restart Visual Studio 2015 and transform the first template the message pops up again.
This does not happen in Visual Studio 2013.
Some hints that may have something to do with this:
The actual text template that is called is published by a VS extension that is installed in the admin extensions directory ($ProgramFiles$\Microsoft Visual Studio 12.0\Common7\IDE\Extensions).
We are using our own custom code generator (that derives from TemplatedCodeGenerator).
Any ideas?
I have found the solution to this one a little by chance.
The problem was that the assembly containing the custom code generator was referencing Microsoft.VisualStudio.TextTemplating.VSHost.12.0 instead of version 14.0 as for Visual Studio 2015.
Oddly enough the transformation did not complain about the problem with the reference but completely ignored the VS option to stop showing the security dialog (may be because it was reading it from the wrong place?).
After correcting the reference, the problem never happened again.
When using WPP in Visual Studio (2012) each occurence of TraceEvents(...) has a wavy underline and the help text is e.g.
#define TraceEvents WPP_(CALL)
error: identifier WPP_Call_Foo_cppNNN not defined
Well, it is defined, in the .tmh header file created by the WPP preprocessor and the project compiles just fine. But Visual Studio doesn't scan and/or recognize this file.
Is there a practical way of getting rid of those squiggles?
For now I work around the problem by putting
#ifdef __INTELLISENSE__
#undef TraceEvents
#define TraceEvents(a,b,...)
#endif
in one of the header files that are included after the .tmh in all of the files anyway.
The define __INTELLISENSE__ is mentioned in http://blogs.msdn.com/b/vcblog/archive/2011/03/29/10146895.aspx
Edit for Visual Studio 2012:
It appears you've reached the analysis limit of the preprocessor in Visual Studio 2012's IntelliSense engine. If you replace the TraceEvents reference with WPP_Call_Foo_cppNNN, it actually resolves the identifier without problems (until you rebuild the solution and the tmh header changes).
The solution is to load the solution in Visual Studio 2013, and choose to not upgrade the compiler toolchain, thus preserving backwards compatibility with Visual Studio 2012.
Previous Answer for Visual Studio 2013:
This was tested in Visual Studio 2013, so it may not apply to Visual Studio 2012. I couldn't find a release of the WDK that supports Visual Studio 2012, so you'll need to let me know how to configure the environment if the following steps do not work.
After building your project (to ensure the .tmh files exist), execute the Project → Rescan Solution command.
I also recommend you associate the files with the C++ editor through the following steps:
Open Tools → Options... → Text Editor → File Extension
Associate extension tmh with editor Microsoft Visual C++
Switch off the Live Semantic Errors in Options->Text Editor->C/C++ -> Advanced ...
I built a macro today in VS.. testing as I went, and it worked great. I proceeded to build another, but accidentally pasted it into EnvironmentVariables Module... I removed it, and saved, but now no Macros that I create work. I tried the built-in samples, such as insert date, and it worked, but nothing custom works.
Thanks,
Ben
Not to steal anybody's thunder, but I was unable to add comments as I'm apparently considered a person of ill repute, so I'll just add this information as a separate answer.
The page cited in a previous (correct and very helpful) answer by David Coster has since been updated to reflect the fact that it is no longer necessary to uninstall the offending update. Macros can be re-enabled by changing some config files, as described below:
Update (February 18): To restore Visual Studio 2010 macros functionality without removing Windows updates, you can add the
AllowDComReflection configuration setting to vsmsvr10.exe.config, vsaenv10.exe.config and devenv.exe.config files (note, you need to run your editor with admin rights for correct modification of these files):
<configuration>
<runtime>
<AllowDComReflection enabled="true"/>
On a 64-bit Windows machine default paths to these files are:
"C:\Program Files (x86)\Common Files\Microsoft Shared\VSA\9.0\VsaEnv\vsmsvr10.exe.config"
"C:\Program Files (x86)\Common Files\Microsoft Shared\VSA\9.0\VsaEnv\vsaenv10.exe.config"
"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe.config"
Each of these files already has the runtime section, you just need to
add the line.
Visit the page cited for full details.
An update on this: in Feb 2014 Microsoft released an update that broke macros in Visual Studio products. After reading the following link I uninstalled KB2898869 on my Win 7 x64 machine and they are working again.
See this link for the full story.
Here is a bit from that link:
Installing recent February 11, 2014 Windows updates breaks Visual Studio 2010 macros functionality. Macros just don’t run any more without an error message. More specifically, it is MS14-009 update “Vulnerabilities in .NET Framework Could Allow Elevation of Privilege (2916607)” (rated as Important) breaks macros. And more specifically it is the Elevation of Privilege part of this update.
.NET 4.5.1 .NET 4.5 .NET 4
Windows 8.1 KB2898871
Windows 8 KB2898870 KB2898865
Windows 7 KB2898869 KB2898864 KB2898855
Windows XP KB2898855
I had the exact same problem.
Turned out to be caused by a syntax error in one of the macros.
To expound upon what #JZumwalt said, Visual Studio / the macro IDE refuses to run any macro if there is a syntax error with even one of your macros.
The easiest way to track this down is to go to Project -> MyMacros Properties. On the build tab, check the box labeled Option Strict On by default. Next, scroll through each of your modules/classes and look for the blue squiggly lines. The vast majority will be harmless like "Option Strict disallows late binding" and "Option Strict disallows implicit conversion from Foo to Bar".
But as your scrolling through, you will now see the one lone syntax error that is preventing you from running your macros.
This happened to me and the problem was an extra END SUB at the bottom of the entire module--nothing to do with the macro I thought had problems at all.
Microsoft Visual Studio patch released for restoring Macro functionality:
http://www.microsoft.com/en-us/download/confirmation.aspx?id=42541
http://visualstudioextensions.vlasovstudio.com/2014/02/13/visual-studio-2010-macros-stop-working-after-february-2014-windows-update/
I just installed VS on another PC, but this time, while I am coding, it is not marking syntax errors while I am coding..... I need to press F6 to get the errors.
Normally when for example typing the line below, I get 's' underlined saying that there is a mismatch. Any ideas how I can enable this option?
string s = 4;
In order to enable background compilation for C#, which checks you code while typing for many types of errors that are usually only reported when you build the project, you will have to install Service Pack 1 for Visual Studio 2008. If you use the offline MSDN, you will also want to install the updated MSDN Library for Visual Studio 2008 SP1, since there were framework changes from .NET 3.5 RTM to .NET 3.5 SP1 (such as the addition of Entity Framework).
Have you recently deinstalled ReSharper?
(see responses in the same link for other possibilities).
C# has never been as consistent about finding errors while i type as VB.net has. I always assumed it was just due to the freeform nature of the language, which would also explain why C++ never found errors either til build time.
I just moved from Visual Studio 2008 to Visual Studio 2010 (final) and noticed one major flaw:
When I try to use AutoComplete in a C++ source file for managed C++, a small note in the footer appears:
IntelliSense for C++/CLI is not available
Uh, has IntelliSense for C++/CLI been dropped from Visual Studio 2010? Is there any way to get this back? It is rather useful...
You are correct. Unfortunately it has been dropped. You can check this opened issue on Microsoft's Connect website.
I'll just quote them for the sake of the answer:
Unfortunately in this release we had to cut the intellisense support for C++/CLI due to time constraints. If you want to get some intellisense like quick info and memberlist on the native classes you can get it by choosing no /clr support in the project properties.
About getting back intellisense, your best chances for now are using third-party tools like VA Assist for example. I've tried it with Visual Studio 2008 and its IntelliSense is a whole lot better than the default one.
It is available again in Visual Studio 2012.
If you want to get IntelliSense back, install Visual Assist X from Whole Tomato Software. Here you can get a 30-days trial to check the intellisense.
According to the Visual C++ Team Blog, C++/CLI Intellisense will be in the next version of Visual Studio, but not in a service pack for VS2010. That blog post also gives some detail as to what went wrong and led to this sad state.
I don't know if you can use this settings but it work for me. I only check the Common Language RunTime Support for the cpp files that use it. I do not check it for the whole project and I've got intellisense for all the files that don't use the CLI.
Yes! you can enable the IntelliSence, but in a tricky way. Follow these instructions:
Go to your project properties. (Right click on your project name in
Project Explorer, and select Properties. or simply Alt + Enter)
From Configuration Properties, select General
In the right-hand section, find "Common Language Runtime Support"
and change it to "No Common Language Runtime Support".
Click the OK Button.
Now the IntelliSence is working. But a problem is an error when you compile your code! (The error is: error LNK1123: failure during conversion to COFF: file invalid or corrupt)
You can simply go back to Project Properties an change Common Language Runtime Support to "Common Language Runtime Support, Old Syntax (/clr:oldSyntax)".
Good luck.
This solution is only if you don't want Common Language Runtime
It worked for me in VS2010
Go to Project Propreties > Configuration Properties > General > Common Language Runtime Support and set it to No Common Language Runtime Support.
This will work fine just after hitting Apply button.
As mentioned you could install some paid software such as "Visual Assist X from Whole Tomato Software".
or
You could use open source tools that contain intellisense*, one such tool is Qt Creator 3.3.1 (opensource). You have two options, either setup your entire project with Qt to compile using VS2010 compiler, or use Qt to link to your source files and compile with VS2010. You write your code in Qt, save, flip windows to vs2010 and compile and debug.
When changes are saved in Qt, vs2010 will automatically reload the source file in the project and you can compile.