我很久以前就用hlsl/glsl着色器代码看到了这一点 - 使用#include源代码文件将代码粘贴到一个代码中,char*以便在运行时不会发生文件IO.
如果我将它表示为伪代码,它看起来有点像这样:
#define CLSourceToString(filename) " #include "filename" "
const char* kernel = CLSourceToString("kernel.cl");
Run Code Online (Sandbox Code Playgroud)
现在当然#define不会起作用,因为它只会尝试使用这些引号来启动字符串.
我有一个Visual Studio 2010扩展,一个.vsix文件.我可以获取我的Visual Studio特定实例的DTE实例,我通过打印dte_instance.Solution.Fullname来确认.但是对于我的DTE2实例,它似乎向我提供了有关错误的Visual Studio实例的信息.
这是工作流程:Visual Studio开发IDE打开,具有扩展的代码.启动项目,这将导致启动一个新的Visual Studio实例,其中安装了扩展.单击运行以下代码的菜单按钮(在新IDE中):
DTE dte;
DTE2 dte2, dte2Macros;
dte = (DTE)GetService(typeof(DTE));
dte2 = (DTE2)System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE.10.0");
dte2Macros = (DTE2)dte2.MacrosIDE;
//this returns what I expect, the solution name in the newer IDE.
MessageBox.Show("solution name: " + dte.Solution.FullName);
//code to get the startup project from MSDN
//http://msdn.microsoft.com/en-us/library/ms228782.aspx
SolutionBuild2 sb = (SolutionBuild2)dte2.Solution.SolutionBuild;
string msg = "";
Int32 configs = sb.SolutionConfigurations.Count;
foreach (String item in (Array)sb.StartupProjects)
{
msg += item;
}
//this returns a project from the development IDE, the one …Run Code Online (Sandbox Code Playgroud) 我正在使用模板化的工会,以确保自己总是得到一个64位字段的指针(即使在32位机器上,因为有数据传输到64位机器)并保存用户和我自己铸件.
template <typename type> union lrbPointer
{
uint64_t intForm;
type ptrForm; //assumed that type is a pointer type
};
//usage
lrbPointer<int*> myPointer;
int integers[4];
myPointer.ptrForm = integers;
myPointer.intForm += 2; //making it easy to jump by less then sizeof(int)
Run Code Online (Sandbox Code Playgroud)
这对我很有用,但我真的很想找到一种方法来制作默认会员.这样用户不需要在他们希望使用的指针之后使用.ptrForm.