style) C code with Visual C++?

We have some old C code with pre-ANSI (K&R-style) function declarations. For example: int foo(x, y) double x, y; { /* do some stuff */ } Is there a compiler switch to enable support for this in Visual C++ 2008? In order to get this to compile put the code in a .c file vs. a .cpp. This instructs Visual Studio to compile the code as C instead of C++

样式)使用Visual C ++的C代码?

我们有一些具有预ANSI(K&R式)函数声明的旧C代码。 例如: int foo(x, y) double x, y; { /* do some stuff */ } 是否有一个编译器开关在Visual C ++ 2008中为此提供支持? 为了得到这个编译把代码放在一个.c文件和一个.cpp文件中。 这指示Visual Studio将代码编译为C而不是C ++

Code weave helper for the standard Dispose pattern?

I have been reading Effective C# and a few other such books/blogs recently and when talking about the standard Dispose pattern (which I'm already using) they all recommend using the class' dispose variable (as defined in that MSDN sample code) at the beginning of every method. Essentially to insure that once Dispose has been called, any attempt to use the object would result in ObjectDis

代码编织助手的标准配置模式?

我最近在阅读有效的C#和其他一些书籍/博客,当谈到标准的Dispose模式(我已经使用它)时,他们都建议使用类的dispose变量(如MSDN示例代码中定义的)每种方法的开始。 基本上要确保一旦调用Dispose,任何使用该对象的尝试都将导致ObjectDisposedException。 这是有道理的,但是在足够大的代码库中需要大量的体力劳动,并且依靠人们记住这么做。 所以我正在寻找更好的方法。 我最近遇到并开始使用notifypropertyweaver,它

VS2010 Intellisense disabling itself randomly, ReSharper installed

I am currently using Visual Studio 2010 Version 4.0.30319 and programming in C#. I have ReSharper 6.1 installed as well. Everything on my computer is up-to-date. Here are my system specifications if needed: Operating System: Windows 7 Home Premium 64-bit (6.1, Build 7601) Service Pack 1 (7601.win7sp1_gdr.110622-1506) System Manufacturer: Dell Inc. System Model: Inspiron N5030 BIOS

VS2010 Intellisense随机禁用ReSharper

我目前正在使用Visual Studio 2010 4.0.30319版和C#编程。 我也安装了ReSharper 6.1。 我的电脑上的所有内容都是最新的。 如果需要,以下是我的系统规格: 操作系统:Windows 7 Home Premium 64位(6.1,Build 7601) Service Pack 1(7601.win7sp1_gdr.110622-1506) 系统制造商:戴尔公司 系统型号:Inspiron N5030 BIOS:Phoenix ROM BIOS PLUS版本1.10 A02 处理器:奔腾(R)双核CPU T4500 @ 2.30GHz(2

How do I check if a given string is a legal/valid file name under Windows?

I want to include a batch file rename functionality in my application. A user can type a destination filename pattern and (after replacing some wildcards in the pattern) I need to check if it's going to be a legal filename under Windows. I've tried to use regular expression like [a-zA-Z0-9_]+ but it doesn't include many national-specific characters from various languages (eg umlauts

如何在Windows下检查给定的字符串是否为合法/有效的文件名?

我想在我的应用程序中包含批处理文件重命名功能。 用户可以键入一个目标文件名模式,并且(在替换模式中的某些通配符之后),我需要检查它是否将成为Windows下的合法文件名。 我试过使用像[a-zA-Z0-9_]+这样的正则表达式,但它不包含来自各种语言的许多国家特定字符(例如元音变音等)。 做这种检查的最佳方法是什么? 您可以从Path.GetInvalidPathChars和GetInvalidFileNameChars获取无效字符的列表。 UPD:请参阅Steve

How can unmanaged memory usage be viewed?

How can unmanaged memory usage be viewed and monitored within Visual Studio in ac# project? Is there a way to check if allocated memory has been properly deleted later while debugging? Code: pv_Memory = Marshal.AllocHGlobal(0x200000); I am attempting to use the 'Diagnostics Tools' within Visual Studio 2015 and can see memory increasing, though it does not appear to separate out unman

如何查看非托管内存使用情况?

在Visual Studio中如何在ac#项目中查看和监视非托管内存使用情况? 有没有办法在调试后检查分配的内存是否被正确删除? 代码:pv_Memory = Marshal.AllocHGlobal(0x200000); 我试图在Visual Studio 2015中使用“诊断工具”,并且可以看到内存在增加,尽管它似乎没有分离出非托管对象和内存。 有小费吗? 谢谢。 配置:1. Visual Studio 2015 2.引用第三方.NET库的C#应用​​程序,它是非托管库的包装3. Windows 7 当

Detect unmanaged memory leak in a managed application

I'm working on a project which the main application is written in C# and some of the infrastructure is in C++. I've just found that I have unmanaged memory leaks which I try to trace down. I've been marking code in and out for days already but was able to find only some of the leaks. All leak detectors apps (purify, leak detector, etc') work only on unmanaged applications (whi

检测托管应用程序中的非托管内存泄漏

我正在研究一个主应用程序使用C#编写的项目,其中一些基础结构使用C ++。 我刚刚发现我有非托管内存泄漏,我试图追查。 我已经为代码进出了几天,但只能找到一些泄漏。 所有泄漏检测器应用程序(净化,泄漏检测器等)仅适用于非托管应用程序(而我的C#)。 对这种情况有任何好的内存泄漏检测器的想法? 任何其他想法? 非常感谢。 你有没有试过ANTS内存分析器? 为我工作得很好。 http://www.red-gate.com/produ

Tool for detecting memory corruption in a mixed

Can anyone recommend a free or commercial tool that detects memory corruption (NOT memory leak) in a C# 4.0 application that calls unmanaged C++ libraries via a C++/CLI bridge? We are using Redgate Ants but it is not designed to help with the unmanaged code (this is where the memory corruption occurs). Thanks. 从来没有使用它,但根据其他人在SO写这个http://memprofiler.com/是一个托管分析器提供本

用于检测混合内存中的内存损坏的工具

任何人都可以推荐一款免费或商业工具来检测C#4.0应用程序中通过C ++ / CLI桥调用非托管C ++库的内存损坏情况(而不是内存泄漏)吗? 我们使用的是Redgate Ants,但它不是用来帮助处理非托管代码(这是发生内存损坏的地方)。 谢谢。 从来没有使用它,但根据其他人在SO写这个http://memprofiler.com/是一个托管分析器提供本地内存信息(在一个工具)...

debugging in mixed mode with native C++, managed c++ cli, and c# solution

I have a multithreaded project im working on and the startup project is set to ac# project that runs my UI. Then there is a whole series of underlying c++ native projects which are connected to the C# by managed C++/CLI projects. I've enabled in the c# start up project 'Enable Unmanaged debug' and when I attempt to debug the native code, I am able to hit break points I set. However

在本机C ++混合模式下调试,托管c ++ cli和c#解决方案

我有一个多线程项目即时通讯工具,启动项目设置为运行我的用户界面的ac#项目。 然后有一系列底层c ++本地项目,它们通过托管的C ++ / CLI项目连接到C#。 我已经启用了c#启动项目“启用非托管调试”,当我尝试调试本机代码时,我能够达到我设置的中断点。 但是,在我尝试再次运行并尝试再次触发一个中断点后,它会挂起。 例如,如果我有一个循环,我会在每次迭代时尝试打开它,在第二次迭代之后,程序会挂起,我必须强制退出

memory leak when calling unmanaged code from managed code in Windows 7

When I call an unmanaged C++ code from my C# code, I seem to have some kind of a memory leak. The C++ reads data from a file using ifstream.read, and writes it to a Vector. This happens only after upgrading to Windows 7, doesn't happen on Vista, but if I use a version of the native dll that was compiled on Vista, it doesn't change anything! If I run the same C++ code directly, witho

在Windows 7中从托管代码调用非托管代码时发生内存泄漏

当我从C#代码中调用一个非托管的C ++代码时,我似乎有某种内存泄漏。 C ++使用ifstream.read从文件读取数据,并将其写入Vector。 这只会在升级到Windows 7之后才会发生,在Vista上不会发生,但如果我使用在Vista上编译的原生dll版本,它不会改变任何内容! 如果我直接运行相同的C ++代码,而没有托管互操作,则不存在内存泄漏! 如果我运行托管进程,但在vshost进程中,则不会发生内存泄漏! 这是呼叫签名:

What strategies and tools are useful for finding memory leaks in .NET?

I wrote C++ for 10 years. I encountered memory problems, but they could be fixed with a reasonable amount of effort. For the last couple of years I've been writing C#. I find I still get lots of memory problems. They're difficult to diagnose and fix due to the non-determinancy, and because the C# philosophy is that you shouldn't have to worry about such things when you very defin

什么策略和工具对于在.NET中查找内存泄漏很有用?

我写了C ++ 10年。 我遇到了记忆问题,但是可以通过合理的努力来修复它们。 在过去的几年里,我一直在写C#。 我发现我仍然有很多内存问题。 由于非决定因素,它们很难诊断和修复,并且因为C#的理念是,当你非常确定的时候,你不应该担心这样的事情。 我发现的一个特殊问题是我必须明确地处理和清理代码中的所有内容。 如果我不这样做,那么内存分析器并不会真正起到帮助作用,因为有太多的cha floating声在你尝试向你