Tag: c ++ cli

从C ++ / CLI Visual Studio 2010调用使用VS 2005编译的本机C – 无法打开.lib文件…

嗨,我想调用从C dll到C ++ / CLI的函数。 C函数声明为extern。 我按照本教程链接dll: http : //social.msdn.microsoft.com/Forums/en/Vsexpressvc/thread/84deabaa-ae82-47cc-aac0-592f5a8dfa22然后在我的C ++ / CLI dll中我有以下内容: // testWrapper.h #pragma once using namespace System; namespace testWrapper { extern “C” int GtoCalcImpliedVolatility2( double premium, int optionType, double underPrice, double strike, double yearsToExpiry, double yearsToPayment, double volGuess, double discountRate, double dividendRate, double growthRate, double *impliedVol); public ref class MyNamesSplitterClass { […]

应该如何将多个Fortran字符串传递给C?

要将Fortran字符串传递给C,还会使用变量的大小传递隐藏参数。 这是一个有效的fortran定义,以及C(实际上是C ++ / CLI)方法: interface subroutine AppendExtension( + Filename) + bind(C, name=”AppendExtension”) character *1, intent(inout):: Filename end subroutine AppendExtension end interface 这是被调用的C ++ / CLI: extern “C” { void __declspec(dllexport) __cdecl AppendExtension( char * name, int buffersize) { String^ clistr = gcnew String(name); clistr = System::IO::Path::ChangeExtension(clistr->Trim(), gcnew String(“OUT”)); IntPtr p = Marshal::StringToHGlobalAnsi(clistr); char *pNewCharStr […]

如何在C ++ / CLI中包装C库回调

给定以下C库以及要求设置缓冲区的回调事件,如何以类型安全的方式编写适当的C ++ / CLI包装器? // The callback signature typedef void (__cdecl *BUFFERALLOCATOR)(void *opaque, void **buffer); // A struct that contains the context of the library struct lib_context_base_s { // The stored callback function pointer BUFFERALLOCATOR buffer_allocator; // Opaque pointer that contain the local context. Needed in C because // C doesn’t have closures (functions that […]

我可以在C ++结构上实现.ToString()以进行调试吗?

在C#中,如果我定义了一个struct,我也可以覆盖ToString()。 然后当我调试并添加一个监视或将鼠标hover在结构的一个实例上时,工具提示将是计算的ToString()而不是结构的类型名称。 我能以某种方式在C ++和/或C ++ / CLI中这样做吗? 也就是说,我可以将方法定义为结构的一部分(或做其他任何事情),这会导致监视值/工具提示显示我选择的字符串吗? Visual Studio for C / C ++中的默认字符串呈现是所有结构的字段值的列表(或者可以卡在小框中的数量)。 我的类型都是C风格的结构。 (在我将文件转换为.cpp并修复了一些类型问题之前,它实际上是用C编写的,因此我可以在CLI中运行它。)这是一个示例结构: struct other_dollars_node { struct other_dollars_node *next_other_dollars; override *overrides; long other_dollars_id; tm effective_date; double amount; } 我对C ++ / CLI的经验很少 – 我的大部分经验都是使用原生C / C ++和C#。 我正在使用Visual Studio 2013。 更新:由于几乎所有现有代码都使用本机C语法,并且我更喜欢无需重构的解决方案,因此CLI方面可能不那么重要。

用于在Windows控制台中运行的游戏的C ++控件

我正在尝试制作一个在命令提示符下运行的小型2人游戏。 在我开始制作球员控制之前,一切都很好。 因此,为了捕获键盘键,我认为最好的解决方案是使用getch()函数。 这是因为getch()即时获取键,而不是在屏幕上显示,等待输入或其他键被按下。 据我所知,实现这一目标的代码非常简单: c=getch(); switch(c) { case ‘a’: make player 1 go left break; case ‘d’: make player 1 go right break; case ‘s’: make player 1 go down break; case ‘w’: make player 1 go up break; case ‘h’: make player 2 go left break; case ‘k’: make player 2 go right […]